dotnet-installer/eng/common/build.ps1

139 lines
4.7 KiB
PowerShell
Raw Normal View History

2018-10-22 05:07:26 +00:00
[CmdletBinding(PositionalBinding=$false)]
Param(
2018-12-19 20:55:42 +00:00
[string][Alias('c')]$configuration = "Debug",
[string] $projects,
[string][Alias('v')]$verbosity = "minimal",
2018-10-22 05:07:26 +00:00
[string] $msbuildEngine = $null,
2018-12-19 20:55:42 +00:00
[bool] $warnAsError = $true,
[bool] $nodeReuse = $true,
[switch][Alias('r')]$restore,
2018-10-22 05:07:26 +00:00
[switch] $deployDeps,
2018-12-19 20:55:42 +00:00
[switch][Alias('b')]$build,
2018-10-22 05:07:26 +00:00
[switch] $rebuild,
[switch] $deploy,
[switch][Alias('t')]$test,
2018-10-22 05:07:26 +00:00
[switch] $integrationTest,
[switch] $performanceTest,
[switch] $sign,
[switch] $pack,
[switch] $publish,
2018-12-19 20:55:42 +00:00
[switch][Alias('bl')]$binaryLog,
2018-10-22 05:07:26 +00:00
[switch] $ci,
[switch] $prepareMachine,
[switch] $help,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)
. $PSScriptRoot\tools.ps1
function Print-Usage() {
Write-Host "Common settings:"
2018-12-19 20:55:42 +00:00
Write-Host " -configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)"
Write-Host " -binaryLog Output binary log (short: -bl)"
2018-10-22 05:07:26 +00:00
Write-Host " -help Print help and exit"
Write-Host ""
Write-Host "Actions:"
2018-12-19 20:55:42 +00:00
Write-Host " -restore Restore dependencies (short: -r)"
Write-Host " -build Build solution (short: -b)"
2018-10-22 05:07:26 +00:00
Write-Host " -rebuild Rebuild solution"
Write-Host " -deploy Deploy built VSIXes"
Write-Host " -deployDeps Deploy dependencies (e.g. VSIXes for integration tests)"
Write-Host " -test Run all unit tests in the solution (short: -t)"
2018-10-22 05:07:26 +00:00
Write-Host " -integrationTest Run all integration tests in the solution"
Write-Host " -performanceTest Run all performance tests in the solution"
Write-Host " -pack Package build outputs into NuGet packages and Willow components"
2018-10-22 05:07:26 +00:00
Write-Host " -sign Sign build outputs"
Write-Host " -publish Publish artifacts (e.g. symbols)"
Write-Host ""
Write-Host "Advanced settings:"
Write-Host " -projects <value> Semi-colon delimited list of sln/proj's to build. Globbing is supported (*.sln)"
Write-Host " -ci Set when running on CI server"
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
2018-10-22 05:07:26 +00:00
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
Write-Host ""
2018-10-22 05:07:26 +00:00
Write-Host "Command line arguments not listed above are passed thru to msbuild."
Write-Host "The above arguments can be shortened as much as to be unambiguous (e.g. -co for configuration, -t for test, etc.)."
}
2018-12-19 20:55:42 +00:00
function InitializeCustomToolset {
if (-not $restore) {
return
2018-10-22 05:07:26 +00:00
}
2018-12-19 20:55:42 +00:00
$script = Join-Path $EngRoot "restore-toolset.ps1"
2018-10-22 05:07:26 +00:00
2018-12-19 20:55:42 +00:00
if (Test-Path $script) {
. $script
}
}
function Build {
$toolsetBuildProj = InitializeToolset
InitializeCustomToolset
2018-12-19 20:55:42 +00:00
$bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" }
if ($projects) {
# Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons.
# Explicitly set the type as string[] because otherwise PowerShell would make this char[] if $properties is empty.
[string[]] $msbuildArgs = $properties
$msbuildArgs += "/p:Projects=$projects"
$properties = $msbuildArgs
}
2018-10-22 05:07:26 +00:00
2018-12-19 20:55:42 +00:00
MSBuild $toolsetBuildProj `
$bl `
2018-10-22 05:07:26 +00:00
/p:Configuration=$configuration `
/p:RepoRoot=$RepoRoot `
/p:Restore=$restore `
/p:DeployDeps=$deployDeps `
/p:Build=$build `
/p:Rebuild=$rebuild `
/p:Deploy=$deploy `
/p:Test=$test `
/p:Pack=$pack `
/p:IntegrationTest=$integrationTest `
/p:PerformanceTest=$performanceTest `
/p:Sign=$sign `
/p:Publish=$publish `
@properties
2018-12-19 20:55:42 +00:00
}
try {
if ($help -or (($null -ne $properties) -and ($properties.Contains("/help") -or $properties.Contains("/?")))) {
2018-12-19 20:55:42 +00:00
Print-Usage
exit 0
}
2018-10-22 05:07:26 +00:00
2018-12-19 20:55:42 +00:00
if ($ci) {
$binaryLog = $true
$nodeReuse = $false
2018-10-22 05:07:26 +00:00
}
2018-12-19 20:55:42 +00:00
# Import custom tools configuration, if present in the repo.
# Note: Import in global scope so that the script set top-level variables without qualification.
$configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1"
if (Test-Path $configureToolsetScript) {
. $configureToolsetScript
}
if (($restore) -and ($null -eq $env:DisableNativeToolsetInstalls)) {
InitializeNativeTools
}
2018-12-19 20:55:42 +00:00
Build
2018-10-22 05:07:26 +00:00
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
ExitWithExitCode 1
}
2018-12-19 20:55:42 +00:00
ExitWithExitCode 0