Skip to content

Commit 4e70997

Browse files
committed
Fix build script
Use `throw` to exit when a `dotnet` command fails so that errors are properly reported on AppVeyor. See also #372
1 parent 325577e commit 4e70997

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Build.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
echo "build: Build started"
1+
Write-Output "build: Build started"
22

33
Push-Location $PSScriptRoot
44

55
if(Test-Path .\artifacts) {
6-
echo "build: Cleaning .\artifacts"
7-
Remove-Item .\artifacts -Force -Recurse
6+
Write-Output "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
88
}
99

1010
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
@@ -13,20 +13,20 @@ $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch
1313
$commitHash = $(git rev-parse --short HEAD)
1414
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1515

16-
echo "build: Package version suffix is $suffix"
17-
echo "build: Build version suffix is $buildSuffix"
16+
Write-Output "build: Package version suffix is $suffix"
17+
Write-Output "build: Build version suffix is $buildSuffix"
1818

1919
& dotnet build --configuration Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
2020

21-
if($LASTEXITCODE -ne 0) { exit 1 }
21+
if($LASTEXITCODE -ne 0) { throw 'build failed' }
2222

2323
if($suffix) {
2424
& dotnet pack src\Serilog.Settings.Configuration --configuration Release --no-build --no-restore -o artifacts --version-suffix=$suffix
2525
} else {
2626
& dotnet pack src\Serilog.Settings.Configuration --configuration Release --no-build --no-restore -o artifacts
2727
}
2828

29-
if($LASTEXITCODE -ne 0) { exit 2 }
29+
if($LASTEXITCODE -ne 0) { throw 'pack failed' }
3030

3131
Write-Output "build: Testing"
3232

@@ -35,4 +35,4 @@ Write-Output "build: Testing"
3535
# The _reported_ runtime is wrong but the _actual_ used runtime is correct, see https://github.com/microsoft/vstest/issues/2037#issuecomment-720549173
3636
& dotnet test test\Serilog.Settings.Configuration.Tests\bin\Release\*\Serilog.Settings.Configuration.Tests.dll --parallel
3737

38-
if($LASTEXITCODE -ne 0) { exit 3 }
38+
if($LASTEXITCODE -ne 0) { throw 'unit tests failed' }

0 commit comments

Comments
 (0)