forked from GitTools/GitVersion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
executable file
·74 lines (66 loc) · 2.06 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
#!/usr/bin/env pwsh
<#
.PARAMETER Stage
The build stage to execute.
.PARAMETER Target
The build script target to run.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER ScriptArgs
Remaining arguments are added here.
#>
[CmdletBinding()]
Param(
[ValidateSet("artifacts", "build", "docker", "docs", "publish", "release")]
[string]$Stage = "build",
[string]$Target = "Default",
[string]$Verbosity = "Normal",
[Alias("DryRun","Noop")]
[switch]$WhatIf,
[switch]$Exclusive,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
$env:DOTNET_ROLL_FORWARD="major"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
$env:DOTNET_NOLOGO=$true
# ###########################################################################
# RUN BUILD SCRIPT
# ###########################################################################
# Build the argument list.
$Arguments = @{
target=$Target;
verbosity=$Verbosity;
dryrun=$WhatIf;
exclusive=$Exclusive;
nuget_useinprocessclient=$true;
}.GetEnumerator() | ForEach-Object {
if ($($_.Key -ceq "dryrun") -or ($_.Key -ceq "exclusive")) {
if ($_.Value -eq $true) {
# switches must not be assigned true or false, but must be passed to indicate true.
"--{0}" -f $_.Key
}
}
else {
if ($_.Value -cne "") {
if ($_.Value -as [string] -contains " ") {
$_.Value = "$($_.Value)" # if it contains spaces, enclose it.
}
"--{0}={1}" -f $_.Key, $_.Value
}
}
};
$Arguments | Join-String -Separator " " | Write-Verbose
# Start Cake
Write-Host "Running build stage $Stage..."
$cmdline = "& dotnet run --project build/$Stage/$Stage.csproj -- $Arguments $ScriptArgs"
Write-Verbose $cmdline
Invoke-Command -ScriptBlock ([scriptblock]::Create($cmdline))
if ($env:APPVEYOR) {
$host.SetShouldExit($LASTEXITCODE)
}
exit $LASTEXITCODE