|
| 1 | +[CmdletBinding(PositionalBinding=$false)] |
| 2 | +Param( |
| 3 | + [string][Alias('c')]$configuration = "Debug", |
| 4 | + [string] $projects, |
| 5 | + [string][Alias('v')]$verbosity = "minimal", |
| 6 | + [string] $msbuildEngine = $null, |
| 7 | + [bool] $warnAsError = $true, |
| 8 | + [bool] $nodeReuse = $true, |
| 9 | + [switch][Alias('r')]$restore, |
| 10 | + [switch] $deployDeps, |
| 11 | + [switch][Alias('b')]$build, |
| 12 | + [switch] $rebuild, |
| 13 | + [switch] $deploy, |
| 14 | + [switch][Alias('t')]$test, |
| 15 | + [switch] $integrationTest, |
| 16 | + [switch] $performanceTest, |
| 17 | + [switch] $sign, |
| 18 | + [switch] $pack, |
| 19 | + [switch] $publish, |
| 20 | + [switch][Alias('bl')]$binaryLog, |
| 21 | + [switch] $ci, |
| 22 | + [switch] $prepareMachine, |
| 23 | + [switch] $help, |
| 24 | + [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties |
| 25 | +) |
| 26 | + |
| 27 | +. $PSScriptRoot\tools.ps1 |
| 28 | + |
| 29 | +function Print-Usage() { |
| 30 | + Write-Host "Common settings:" |
| 31 | + Write-Host " -configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)" |
| 32 | + Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" |
| 33 | + Write-Host " -binaryLog Output binary log (short: -bl)" |
| 34 | + Write-Host " -help Print help and exit" |
| 35 | + Write-Host "" |
| 36 | + |
| 37 | + Write-Host "Actions:" |
| 38 | + Write-Host " -restore Restore dependencies (short: -r)" |
| 39 | + Write-Host " -build Build solution (short: -b)" |
| 40 | + Write-Host " -rebuild Rebuild solution" |
| 41 | + Write-Host " -deploy Deploy built VSIXes" |
| 42 | + Write-Host " -deployDeps Deploy dependencies (e.g. VSIXes for integration tests)" |
| 43 | + Write-Host " -test Run all unit tests in the solution (short: -t)" |
| 44 | + Write-Host " -integrationTest Run all integration tests in the solution" |
| 45 | + Write-Host " -performanceTest Run all performance tests in the solution" |
| 46 | + Write-Host " -pack Package build outputs into NuGet packages and Willow components" |
| 47 | + Write-Host " -sign Sign build outputs" |
| 48 | + Write-Host " -publish Publish artifacts (e.g. symbols)" |
| 49 | + Write-Host "" |
| 50 | + |
| 51 | + Write-Host "Advanced settings:" |
| 52 | + Write-Host " -projects <value> Semi-colon delimited list of sln/proj's to build. Globbing is supported (*.sln)" |
| 53 | + Write-Host " -ci Set when running on CI server" |
| 54 | + Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build" |
| 55 | + Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')" |
| 56 | + Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." |
| 57 | + Write-Host "" |
| 58 | + |
| 59 | + Write-Host "Command line arguments not listed above are passed thru to msbuild." |
| 60 | + Write-Host "The above arguments can be shortened as much as to be unambiguous (e.g. -co for configuration, -t for test, etc.)." |
| 61 | +} |
| 62 | + |
| 63 | +function InitializeCustomToolset { |
| 64 | + if (-not $restore) { |
| 65 | + return |
| 66 | + } |
| 67 | + |
| 68 | + $script = Join-Path $EngRoot "restore-toolset.ps1" |
| 69 | + |
| 70 | + if (Test-Path $script) { |
| 71 | + . $script |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +function Build { |
| 76 | + $toolsetBuildProj = InitializeToolset |
| 77 | + InitializeCustomToolset |
| 78 | + |
| 79 | + $bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "Build.binlog") } else { "" } |
| 80 | + |
| 81 | + if ($projects) { |
| 82 | + # Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons. |
| 83 | + # Explicitly set the type as string[] because otherwise PowerShell would make this char[] if $properties is empty. |
| 84 | + [string[]] $msbuildArgs = $properties |
| 85 | + $msbuildArgs += "/p:Projects=$projects" |
| 86 | + $properties = $msbuildArgs |
| 87 | + } |
| 88 | + |
| 89 | + MSBuild $toolsetBuildProj ` |
| 90 | + $bl ` |
| 91 | + /p:Configuration=$configuration ` |
| 92 | + /p:RepoRoot=$RepoRoot ` |
| 93 | + /p:Restore=$restore ` |
| 94 | + /p:DeployDeps=$deployDeps ` |
| 95 | + /p:Build=$build ` |
| 96 | + /p:Rebuild=$rebuild ` |
| 97 | + /p:Deploy=$deploy ` |
| 98 | + /p:Test=$test ` |
| 99 | + /p:Pack=$pack ` |
| 100 | + /p:IntegrationTest=$integrationTest ` |
| 101 | + /p:PerformanceTest=$performanceTest ` |
| 102 | + /p:Sign=$sign ` |
| 103 | + /p:Publish=$publish ` |
| 104 | + @properties |
| 105 | +} |
| 106 | + |
| 107 | +try { |
| 108 | + if ($help -or (($null -ne $properties) -and ($properties.Contains("/help") -or $properties.Contains("/?")))) { |
| 109 | + Print-Usage |
| 110 | + exit 0 |
| 111 | + } |
| 112 | + |
| 113 | + if ($ci) { |
| 114 | + $binaryLog = $true |
| 115 | + $nodeReuse = $false |
| 116 | + } |
| 117 | + |
| 118 | + # Import custom tools configuration, if present in the repo. |
| 119 | + # Note: Import in global scope so that the script set top-level variables without qualification. |
| 120 | + $configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1" |
| 121 | + if (Test-Path $configureToolsetScript) { |
| 122 | + . $configureToolsetScript |
| 123 | + } |
| 124 | + |
| 125 | + Build |
| 126 | +} |
| 127 | +catch { |
| 128 | + Write-Host $_ |
| 129 | + Write-Host $_.Exception |
| 130 | + Write-Host $_.ScriptStackTrace |
| 131 | + ExitWithExitCode 1 |
| 132 | +} |
| 133 | + |
| 134 | +ExitWithExitCode 0 |
0 commit comments