-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.ps1
67 lines (54 loc) · 2.34 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
Param(
[switch] $Release,
[string] $SigningCertThumbprint,
[string] $TimestampServer
)
$ErrorActionPreference = 'Stop'
# Options
$configuration = 'Release'
$artifactsDir = Join-Path (Resolve-Path .) 'artifacts'
$packagesDir = Join-Path $artifactsDir 'Packages'
$testResultsDir = Join-Path $artifactsDir 'Test results'
$logsDir = Join-Path $artifactsDir 'Logs'
# Detection
. $PSScriptRoot\build\Get-DetectedCiVersion.ps1
$versionInfo = Get-DetectedCiVersion -Release:$Release
Update-CiServerBuildName $versionInfo.ProductVersion
Write-Host "Building using version $($versionInfo.ProductVersion)"
$dotnetArgs = @(
'--configuration', $configuration
'/p:RepositoryCommit=' + $versionInfo.CommitHash
'/p:Version=' + $versionInfo.ProductVersion
'/p:PackageVersion=' + $versionInfo.PackageVersion
'/p:FileVersion=' + $versionInfo.FileVersion
'/p:ContinuousIntegrationBuild=' + ($env:CI -or $env:TF_BUILD)
)
# Build
dotnet build /bl:$logsDir\build.binlog @dotnetArgs
if ($LastExitCode) { exit 1 }
if ($SigningCertThumbprint) {
. build\SignTool.ps1
SignTool $SigningCertThumbprint $TimestampServer (
Get-ChildItem src\Techsola.InstantReplay\bin\$configuration -Recurse -Include Techsola.InstantReplay.dll)
}
# Pack
Remove-Item -Recurse -Force $packagesDir -ErrorAction Ignore
dotnet pack src\Techsola.InstantReplay --no-build --output $packagesDir /bl:$logsDir\pack.binlog @dotnetArgs
if ($LastExitCode) { exit 1 }
if ($SigningCertThumbprint) {
# Waiting for 'dotnet sign' to become available (https://github.com/NuGet/Home/issues/7939)
$nuget = 'tools\nuget.exe'
if (-not (Test-Path $nuget)) {
New-Item -ItemType Directory -Force -Path tools
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $nuget
}
# Workaround for https://github.com/NuGet/Home/issues/10446
foreach ($extension in 'nupkg', 'snupkg') {
& $nuget sign $packagesDir\*.$extension -CertificateFingerprint $SigningCertThumbprint -Timestamper $TimestampServer
}
}
# Test
Remove-Item -Recurse -Force $testResultsDir -ErrorAction Ignore
dotnet test --no-build --configuration $configuration --logger trx --results-directory $testResultsDir /bl:"$logsDir\test.binlog"
if ($LastExitCode) { exit 1 }