Skip to content

Commit b56458b

Browse files
committed
Implemented that build script stops on first failure.
1 parent 2e07fd6 commit b56458b

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Build.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,36 @@ param
66
[switch] $SkipTests = $false
77
)
88

9+
$ErrorActionPreference = "Stop"
10+
11+
function Exec([scriptblock] $Command)
12+
{
13+
$global:LastExitCode = 0
14+
& $Command
15+
16+
if ($global:LastExitCode -ne 0)
17+
{
18+
Throw "Command failed: $Command"
19+
}
20+
}
21+
922
Push-Location $PSScriptRoot
1023
try
1124
{
1225
Write-Output "Cleaning..."
13-
dotnet clean --configuration $Configuration --verbosity minimal --nologo
26+
Exec { dotnet clean --configuration $Configuration --verbosity minimal --nologo }
1427
Get-ChildItem -Path src -Filter *.nupkg -Recurse | Remove-Item -Force
1528

1629
Write-Output "Restoring dependencies..."
17-
dotnet restore
30+
Exec { dotnet restore }
1831

1932
Write-Output "Building..."
20-
dotnet build --configuration $Configuration --verbosity minimal --nologo -p:Version=$Version -p:PackageVersion=$PackageVersion
33+
Exec { dotnet build --configuration $Configuration --verbosity minimal --no-restore --nologo -p:Version=$Version -p:PackageVersion=$PackageVersion }
2134

2235
if (-not $SkipTests)
2336
{
2437
Write-Output "Running unit tests..."
25-
dotnet test --configuration $Configuration --no-build --nologo
38+
Exec { dotnet test --configuration $Configuration --no-build --nologo }
2639
}
2740

2841
Write-Output "Creating artifacts..."

0 commit comments

Comments
 (0)