-
-
Notifications
You must be signed in to change notification settings - Fork 348
/
build.ps1
60 lines (50 loc) · 1.72 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
Param (
[Parameter(Position = 0)]
[string]$Arg0,
[Parameter(ValueFromRemainingArguments = $true)]
[Object[]]$RemainingArgs
)
# PSScriptRoot isn't set in PowerShell 2
$minPSVer = [version]"3.0"
if (($PSVersionTable.PSVersion -lt $minPSVer)) {
[Console]::ForegroundColor = 'red'
[Console]::Error.WriteLine("This script does not support PowerShell $($PSVersionTable.PSVersion).")
[Console]::Error.WriteLine("Please upgrade to PowerShell $minPSVer or later.")
[Console]::ResetColor()
exit
}
# Globals
$NugetVersion = "6.8.0"
$UseExperimental = $false
$RootDir = "${PSScriptRoot}"
$ScriptFile = "${RootDir}/build.cake"
$BuildDir = "${RootDir}/_build"
$ToolsDir = "${BuildDir}/tools"
$NugetExe = "${ToolsDir}/NuGet/${NugetVersion}/nuget.exe"
# Download NuGet
$NugetDir = Split-Path "$NugetExe" -Parent
if (!(Test-Path "$NugetDir")) {
mkdir $nugetDir > $null
}
if (!(Test-Path "$NugetExe")) {
# Enable TLS1.2 for WebClient
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls13
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v${NugetVersion}/nuget.exe", $NugetExe)
}
# Install build packages
dotnet tool install --global Cake.Tool
# Build args
$cakeArgs = @()
if ($Arg0) {
if ($Arg0[0] -eq "-") {
$cakeArgs += "${Arg0}"
} else {
$cakeArgs += "--target=${Arg0}"
}
}
if ($UseExperimental) {
$cakeArgs += "--experimental"
}
# Run Cake
dotnet cake --verbosity Minimal "${ScriptFile}" ${cakeArgs} ${RemainingArgs}
exit $LASTEXITCODE