-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.ps1
44 lines (33 loc) · 1.38 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
param (
[Parameter(Mandatory=$true)]
[ValidatePattern("^\d+\.\d+\.(?:\d+\.\d+$|\d+$)")]
[string]
$ReleaseVersionNumber,
[Parameter(Mandatory=$true)]
[string]
[AllowEmptyString()]
$PreReleaseName
)
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
" PSScriptFilePath = $PSScriptFilePath"
$SolutionRoot = Split-Path -Path $PSScriptFilePath -Parent
# Make sure we don't have a release folder for this version already
$BuildFolder = Join-Path -Path $SolutionRoot -ChildPath "build";
$ReleaseFolder = Join-Path -Path $BuildFolder -ChildPath "Releases\v$ReleaseVersionNumber$PreReleaseName";
if ((Get-Item $ReleaseFolder -ErrorAction SilentlyContinue) -ne $null)
{
Write-Warning "$ReleaseFolder already exists on your local machine. It will now be deleted."
Remove-Item $ReleaseFolder -Recurse
}
# Set the version number and copyright date in project file
$DateYear = (Get-Date).year
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "src\TemporaryDb\TemporaryDb.csproj"
[xml]$project = Get-Content -Path $ProjectPath
$project.Project.PropertyGroup.Version = "$ReleaseVersionNumber$PreReleaseName"
$project.Project.PropertyGroup.Copyright = "Copyright © Josh Clark $DateYear"
$project.Save($ProjectPath)
& dotnet pack --configuration Release --output "$ReleaseFolder"
if (-not $?)
{
throw "The DOTNET pack process returned an error code."
}