-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.ps1
91 lines (76 loc) · 3.99 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
82
83
84
85
86
87
88
89
90
91
[CmdletBinding(PositionalBinding=$false)]
Param(
[switch][Alias('h')]$help,
[switch][Alias('t')]$test,
[ValidateSet("Debug","Release","Checked")][string[]][Alias('c')]$configuration = @("Debug"),
[switch]$vs,
[string][Alias('v')]$verbosity = "minimal",
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)
function Get-Help() {
Write-Host "Common settings:"
Write-Host " -binaryLog (-bl) Output binary log."
Write-Host " -configuration (-c) Build configuration: Debug or Release."
Write-Host " [Default: Debug]"
Write-Host " -help (-h) Print help and exit."
Write-Host " -projects <value> Project or solution file(s) to build."
Write-Host " -verbosity (-v) MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]."
Write-Host " [Default: Minimal]"
Write-Host " -vs Open the solution with Visual Studio using the locally acquired SDK."
Write-Host ""
Write-Host "Actions (defaults to -restore -build):"
Write-Host " -build (-b) Build all source projects."
Write-Host " This assumes -restore has been run already."
Write-Host " -clean Clean the solution."
Write-Host " -pack Package build outputs into NuGet packages."
Write-Host " -publish Publish artifacts (e.g. symbols)."
Write-Host " This assumes -build has been run already."
Write-Host " -rebuild Rebuild all source projects."
Write-Host " -restore Restore dependencies."
Write-Host " -sign Sign build outputs."
Write-Host " -test (-t) Incrementally builds and runs tests."
Write-Host ""
Write-Host "Command-line arguments not listed above are passed through to MSBuild."
Write-Host "The above arguments can be shortened as much as to be unambiguous."
Write-Host "(Example: -con for configuration, -t for test, etc.)."
Write-Host ""
}
if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) {
Get-Help
exit 0
}
if ($vs) {
. $PSScriptRoot\common\tools.ps1
# This tells .NET Core to use the bootstrapped runtime
$env:DOTNET_ROOT=InitializeDotNetCli -install:$true -createSdkLocationFile:$true
# This tells MSBuild to load the SDK from the directory of the bootstrapped SDK
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_ROOT
# Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
$env:PATH=($env:DOTNET_ROOT + ";" + $env:PATH);
# Launch Visual Studio with the locally defined environment variables
$solution = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "MaintenancePackages.sln"
."$solution"
exit 0
}
# Check if an action is passed in
$actions = "b","build","r","restore","rebuild","sign","publish","clean","pack"
$actionPassedIn = @(Compare-Object -ReferenceObject @($PSBoundParameters.Keys) -DifferenceObject $actions -ExcludeDifferent -IncludeEqual).Length -ne 0
if ($null -ne $properties -and $actionPassedIn -ne $true) {
$actionPassedIn = @(Compare-Object -ReferenceObject $properties -DifferenceObject $actions.ForEach({ "-" + $_ }) -ExcludeDifferent -IncludeEqual).Length -ne 0
}
if (!$actionPassedIn) {
$arguments = "-restore -build"
}
foreach ($argument in $PSBoundParameters.Keys)
{
switch($argument)
{
"properties" { $arguments += " " + $properties }
"verbosity" { $arguments += " -$argument " + $($PSBoundParameters[$argument]) }
"configuration" { $configuration = (Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])); $arguments += " -configuration $configuration" }
default { $arguments += " /p:$argument=$($PSBoundParameters[$argument])" }
}
}
Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $arguments"
exit $lastExitCode
exit 0