-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.ps1
35 lines (29 loc) · 1.04 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
#Requires -Version 5.0
Begin {
$ErrorActionPreference = "stop"
}
Process {
function Exec([scriptblock]$Command) {
& $Command
if ($LASTEXITCODE -ne 0) {
throw ("An error occurred while executing command: {0}" -f $Command)
}
}
$workingDir = Join-Path $PSScriptRoot "src"
$outputDir = Join-Path $PSScriptRoot ".output"
$nupkgsPath = Join-Path $outputDir "*.nupkg"
try {
Push-Location $workingDir
Remove-Item $outputDir -Force -Recurse -ErrorAction SilentlyContinue
Exec { & dotnet clean -c Release }
Exec { & dotnet build -c Release }
Exec { & dotnet test -c Release --results-directory "$outputDir" --no-restore -l "trx" -l "console;verbosity=detailed" }
Exec { & dotnet pack -c Release -o "$outputDir" }
if (($null -ne $env:NUGET_SOURCE ) -and ($null -ne $env:NUGET_API_KEY)) {
Exec { & dotnet nuget push "$nupkgsPath" -s $env:NUGET_SOURCE -k $env:NUGET_API_KEY }
}
}
finally {
Pop-Location
}
}