forked from natemcmaster/LettuceEncrypt
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
executable file
·83 lines (67 loc) · 2.4 KB
/
Copy pathbuild.ps1
File metadata and controls
executable file
·83 lines (67 loc) · 2.4 KB
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
82
83
#!/usr/bin/env pwsh
[CmdletBinding(PositionalBinding = $false)]
param(
[ValidateSet('Debug', 'Release')]
$Configuration = $null,
[switch]
$ci,
[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'
& dotnet --info
}
if (-not (Test-Path variable:\IsCoreCLR)) {
$IsWindows = $true
}
$artifacts = "$PSScriptRoot/artifacts/"
Remove-Item -Recurse $artifacts -ErrorAction Ignore
# Versions come from GitVersion, matching what the Package workflow computes. Without the tool the
# build falls back to the version in Directory.Build.props, which is suffixed "-local" so those
# packages are never mistaken for a release. Install with:
#
# dotnet tool install --global GitVersion.Tool
#
[string[]] $versionArgs = @()
if (Get-Command dotnet-gitversion -ErrorAction SilentlyContinue) {
$gitVersion = & dotnet-gitversion /output json | ConvertFrom-Json
$versionArgs += "-p:Version=$($gitVersion.FullSemVer)"
$versionArgs += "-p:PackageVersion=$($gitVersion.FullSemVer)"
$versionArgs += "-p:AssemblyVersion=$($gitVersion.AssemblySemVer)"
$versionArgs += "-p:FileVersion=$($gitVersion.AssemblySemFileVer)"
$versionArgs += "-p:InformationalVersion=$($gitVersion.InformationalVersion)"
write-host -f cyan "GitVersion: $($gitVersion.FullSemVer)"
}
else {
write-host -f yellow 'GitVersion not found. Building with the fallback version from Directory.Build.props.'
write-host -f yellow 'These packages are suffixed "-local" and cannot be published.'
}
[string[]] $formatArgs=@()
if ($ci) {
$formatArgs += '--verify-no-changes'
}
exec dotnet format -v detailed @formatArgs
exec dotnet build --configuration $Configuration '-warnaserror:CS1591' @versionArgs @MSBuildArgs
exec dotnet pack --no-restore --no-build --configuration $Configuration -o $artifacts @versionArgs @MSBuildArgs
[string[]] $testArgs=@()
if ($env:TF_BUILD) {
$testArgs += '--logger', 'trx'
}
exec dotnet test --no-restore --no-build --configuration $Configuration '-clp:Summary' `
--collect:"XPlat Code Coverage" `
@testArgs `
@MSBuildArgs
write-host -f green 'BUILD SUCCEEDED'