Skip to content

Commit a521a79

Browse files
committed
ci(appveyor): check exit codes and fail build
1 parent 2e17c12 commit a521a79

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Build.ps1

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,52 @@ function Get-Version-Suffix-From-Tag
99
return $final
1010
}
1111

12+
function CheckLastExitCode {
13+
param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null)
14+
15+
if ($SuccessCodes -notcontains $LastExitCode) {
16+
$msg = "EXE RETURNED EXIT CODE $LastExitCode"
17+
throw $msg
18+
}
19+
}
20+
1221
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
1322
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
1423

1524
dotnet restore
1625

1726
dotnet test ./test/UnitTests/UnitTests.csproj
27+
CheckLastExitCode
28+
1829
dotnet test ./test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj
30+
CheckLastExitCode
31+
1932
dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
33+
CheckLastExitCode
2034

2135
dotnet build .\src\JsonApiDotNetCore -c Release
36+
CheckLastExitCode
2237

23-
echo "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
38+
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
2439

2540
If($env:APPVEYOR_REPO_TAG -eq $true) {
2641
$revision = Get-Version-Suffix-From-Tag
27-
echo "VERSION-SUFFIX: $revision"
42+
Write-Output "VERSION-SUFFIX: $revision"
2843

2944
IF ([string]::IsNullOrWhitespace($revision)){
30-
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
45+
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
3146
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
47+
CheckLastExitCode
3248
}
3349
Else {
34-
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
50+
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
3551
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
52+
CheckLastExitCode
3653
}
3754
}
3855
Else {
39-
echo "VERSION-SUFFIX: alpha1-$revision"
40-
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision"
56+
Write-Output "VERSION-SUFFIX: alpha1-$revision"
57+
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision"
4158
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision
59+
CheckLastExitCode
4260
}

0 commit comments

Comments
 (0)