-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.ps1
43 lines (34 loc) · 965 Bytes
/
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
36
37
38
39
40
41
42
43
[CmdletBinding(PositionalBinding = $false)]
param(
[ValidateSet('Debug', 'Release')]
$Configuration = $null,
[switch]
$IsOfficialBuild,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$MSBuildArgs
)
Set-StrictMode -Version 1
$ErrorActionPreference = 'Stop'
function exec([string]$_cmd) {
write-host -ForegroundColor DarkGray ">>> $_cmd $args"
$ErrorActionPreference = 'Continue'
& $_cmd @args
$ErrorActionPreference = 'Stop'
if ($LASTEXITCODE -ne 0) {
write-error "Failed with exit code $LASTEXITCODE"
exit 1
}
}
#
# Main
#
if (!$Configuration) {
$Configuration = if ($env:CI -or $IsOfficialBuild) { 'Release' } else { 'Debug' }
}
if ($IsOfficialBuild) {
$MSBuildArgs += '-p:CI=true'
}
$artifacts = "$PSScriptRoot/.artifacts/"
Remove-Item -Recurse $artifacts -ErrorAction Ignore
exec dotnet pack --configuration $Configuration -o $artifacts @MSBuildArgs
write-host -f magenta 'Done'