forked from natemcmaster/CommandLineUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
executable file
·81 lines (64 loc) · 2.38 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env pwsh
[CmdletBinding(PositionalBinding = $false)]
param(
[ValidateSet('Debug', 'Release')]
$Configuration = $null,
[switch]
$ci,
[switch]
$sign,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$MSBuildArgs
)
Set-StrictMode -Version 1
$ErrorActionPreference = 'Stop'
Import-Module -Force -Scope Local "$PSScriptRoot/src/common.psm1"
#
# Main
#
if ($env:CI -eq 'true') {
$ci = $true
}
if (!$Configuration) {
$Configuration = if ($ci) { 'Release' } else { 'Debug' }
}
if ($ci) {
$MSBuildArgs += '-p:CI=true'
}
$CodeSign = $sign -or ($ci -and -not $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT -and ($IsWindows -or -not $IsCoreCLR))
if ($CodeSign) {
$toolsDir = "$PSScriptRoot/.build/tools"
$AzureSignToolPath = "$toolsDir/azuresigntool"
if ($IsWindows) {
$AzureSignToolPath += ".exe"
}
if (-not (Test-Path $AzureSignToolPath)) {
exec dotnet tool install --tool-path $toolsDir `
AzureSignTool `
--version 2.0.17
}
$nstDir = "$toolsDir/nugetsigntool/1.1.4"
$NuGetKeyVaultSignToolPath = "$nstDir/tools/net471/NuGetKeyVaultSignTool.exe"
if (-not (Test-Path $NuGetKeyVaultSignToolPath)) {
New-Item $nstDir -ItemType Directory -ErrorAction Ignore | Out-Null
Invoke-WebRequest https://github.com/onovotny/NuGetKeyVaultSignTool/releases/download/v1.1.4/NuGetKeyVaultSignTool.1.1.4.nupkg `
-OutFile "$nstDir/NuGetKeyVaultSignTool.zip"
Expand-Archive "$nstDir/NuGetKeyVaultSignTool.zip" -DestinationPath $nstDir
}
$MSBuildArgs += '-p:CodeSign=true'
$MSBuildArgs += "-p:AzureSignToolPath=$AzureSignToolPath"
$MSBuildArgs += "-p:NuGetKeyVaultSignToolPath=$NuGetKeyVaultSignToolPath"
}
$artifacts = "$PSScriptRoot/artifacts/"
Remove-Item -Recurse $artifacts -ErrorAction Ignore
exec dotnet build --configuration $Configuration '-warnaserror:CS1591' @MSBuildArgs
exec dotnet pack --no-restore --no-build --configuration $Configuration -o $artifacts @MSBuildArgs
[string[]] $testArgs=@()
if ($PSVersionTable.PSEdition -eq 'Core' -and -not $IsWindows) {
$testArgs += '--framework','netcoreapp2.1'
}
exec dotnet test --no-restore --no-build --configuration $Configuration '-clp:Summary' `
"$PSScriptRoot/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj" `
@testArgs `
@MSBuildArgs
write-host -f magenta 'Done'