|
1 | 1 | # Originally based on https://github.com/serilog/serilog/blob/dev/Build.ps1 - (c) Serilog Contributors |
2 | 2 |
|
3 | | -echo "build: Build started" |
4 | | - |
5 | 3 | Push-Location $PSScriptRoot |
6 | 4 |
|
7 | | -$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; |
8 | | -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
9 | | -$suffix = @{ |
10 | | - $true = "$revision"; |
11 | | - $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] |
12 | | - |
13 | 5 | if(Test-Path .\artifacts) { |
14 | 6 | echo "build: Cleaning .\artifacts" |
15 | 7 | Remove-Item .\artifacts -Force -Recurse |
16 | 8 | } |
17 | 9 |
|
18 | | -& dotnet msbuild "/t:Restore" /p:VersionSuffix=$suffix /p:Configuration=Release |
| 10 | +& dotnet restore --no-cache |
19 | 11 |
|
20 | | -echo "build: Version suffix is $suffix" |
| 12 | +$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; |
| 13 | +$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
| 14 | +$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] |
| 15 | +$commitHash = $(git rev-parse --short HEAD) |
| 16 | +$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] |
| 17 | + |
| 18 | +echo "build: Package version suffix is $suffix" |
| 19 | +echo "build: Build version suffix is $buildSuffix" |
21 | 20 |
|
22 | 21 | foreach ($src in ls src/*) { |
23 | | - Push-Location $src |
| 22 | + Push-Location $src |
24 | 23 |
|
25 | 24 | echo "build: Packaging project in $src" |
26 | 25 |
|
27 | | - & dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix |
28 | | - if($LASTEXITCODE -ne 0) { exit 1 } |
| 26 | + & dotnet build -c Release --version-suffix=$buildSuffix |
| 27 | + |
| 28 | + if ($suffix) { |
| 29 | + & dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build |
| 30 | + } else { |
| 31 | + & dotnet pack -c Release --include-source -o ..\..\artifacts --no-build |
| 32 | + } |
| 33 | + |
| 34 | + if($LASTEXITCODE -ne 0) { exit 1 } |
29 | 35 |
|
30 | | - Pop-Location |
| 36 | + Pop-Location |
31 | 37 | } |
32 | 38 |
|
33 | | -foreach ($test in ls test/*.PerformanceTests) { |
34 | | - Push-Location $test |
| 39 | +foreach ($test in ls test/*.Tests) { |
| 40 | + Push-Location $test |
35 | 41 |
|
36 | | - echo "build: Building performance test project in $test" |
| 42 | + echo "build: Testing project in $test" |
37 | 43 |
|
38 | | - & dotnet build -c Release |
39 | | - if($LASTEXITCODE -ne 0) { exit 2 } |
| 44 | + & dotnet test -c Release |
| 45 | + if($LASTEXITCODE -ne 0) { exit 3 } |
40 | 46 |
|
41 | | - Pop-Location |
| 47 | + Pop-Location |
42 | 48 | } |
43 | 49 |
|
44 | | -foreach ($test in ls test/*.Tests) { |
45 | | - Push-Location $test |
| 50 | +foreach ($test in ls test/*.PerformanceTests) { |
| 51 | + Push-Location $test |
46 | 52 |
|
47 | | - echo "build: Testing project in $test" |
| 53 | + echo "build: Building performance test project in $test" |
48 | 54 |
|
49 | | - & dotnet test -c Release |
50 | | - if($LASTEXITCODE -ne 0) { exit 3 } |
| 55 | + & dotnet build -c Release |
| 56 | + if($LASTEXITCODE -ne 0) { exit 2 } |
51 | 57 |
|
52 | | - Pop-Location |
| 58 | + Pop-Location |
53 | 59 | } |
54 | 60 |
|
55 | 61 | Pop-Location |
0 commit comments