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 " ,
2019-05-18 12:09:41 +00:00
[ string ] $platform = $null ,
2018-12-19 20:55:42 +00:00
[ 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 ,
2019-03-01 13:11:16 +00:00
[ switch ] [ Alias ( 't' ) ] $test ,
2018-10-22 05:07:26 +00:00
[ switch ] $integrationTest ,
[ switch ] $performanceTest ,
[ switch ] $sign ,
[ switch ] $pack ,
[ switch ] $publish ,
2019-10-24 22:05:36 +00:00
[ switch ] $clean ,
2018-12-19 20:55:42 +00:00
[ switch ] [ Alias ( 'bl' ) ] $binaryLog ,
2020-05-12 12:48:04 +00:00
[ switch ] [ Alias ( 'nobl' ) ] $excludeCIBinarylog ,
2018-10-22 05:07:26 +00:00
[ switch ] $ci ,
[ switch ] $prepareMachine ,
2020-08-26 13:09:20 +00:00
[ string ] $runtimeSourceFeed = '' ,
[ string ] $runtimeSourceFeedKey = '' ,
2021-05-06 13:01:50 +00:00
[ switch ] $excludePrereleaseVS ,
2022-09-22 15:04:50 +00:00
[ switch ] $nativeToolsOnMachine ,
2018-10-22 05:07:26 +00:00
[ switch ] $help ,
[ Parameter ( ValueFromRemainingArguments = $true ) ] [ String[] ] $properties
)
2020-03-03 13:38:48 +00:00
# Unset 'Platform' environment variable to avoid unwanted collision in InstallDotNetCore.targets file
# some computer has this env var defined (e.g. Some HP)
if ( $env:Platform ) {
$env:Platform = " "
}
2018-10-22 05:07:26 +00:00
function Print-Usage ( ) {
2019-11-22 13:41:58 +00:00
Write-Host " Common settings: "
Write-Host " -configuration <value> Build configuration: 'Debug' or 'Release' (short: -c) "
Write-Host " -platform <value> Platform configuration: 'x86', 'x64' or any valid Platform value to pass to msbuild "
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) "
Write-Host " -help Print help and exit "
Write-Host " "
Write-Host " Actions: "
Write-Host " -restore Restore dependencies (short: -r) "
Write-Host " -build Build solution (short: -b) "
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) "
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 "
Write-Host " -sign Sign build outputs "
Write-Host " -publish Publish artifacts (e.g. symbols) "
Write-Host " -clean Clean the solution "
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 "
2020-05-12 12:48:04 +00:00
Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl) "
2019-11-22 13:41:58 +00:00
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build "
Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false') "
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified). "
2021-05-06 13:01:50 +00:00
Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio "
2022-09-22 15:04:50 +00:00
Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine) "
2019-11-22 13:41:58 +00:00
Write-Host " "
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-10-22 05:07:26 +00:00
}
2019-12-04 13:31:24 +00:00
. $PSScriptRoot \ tools . ps1
2018-12-19 20:55:42 +00:00
function InitializeCustomToolset {
if ( -not $restore ) {
return
2018-10-22 05:07:26 +00:00
}
2019-11-22 13:41:58 +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
2019-01-18 18:07:17 +00:00
2019-11-22 13:41:58 +00:00
$bl = if ( $binaryLog ) { '/bl:' + ( Join-Path $LogDir 'Build.binlog' ) } else { '' }
$platformArg = if ( $platform ) { " /p:Platform= $platform " } else { '' }
2018-12-19 20:55:42 +00:00
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
2019-09-07 12:43:59 +00:00
# Resolve relative project paths into full paths
$projects = ( $projects . Split ( ';' ) . ForEach ( { Resolve-Path $_ } ) -join ';' )
2018-12-19 20:55:42 +00:00
$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 `
2019-05-18 12:09:41 +00:00
$platformArg `
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 {
2019-11-29 13:31:39 +00:00
if ( $clean ) {
if ( Test-Path $ArtifactsDir ) {
Remove-Item -Recurse -Force $ArtifactsDir
Write-Host 'Artifacts directory deleted.'
}
exit 0
}
2019-12-04 13:31:24 +00:00
2019-11-22 13:41:58 +00:00
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 ) {
2020-05-12 12:48:04 +00:00
if ( -not $excludeCIBinarylog ) {
$binaryLog = $true
}
2018-12-19 20:55:42 +00:00
$nodeReuse = $false
2018-10-22 05:07:26 +00:00
}
2022-09-22 15:04:50 +00:00
if ( $nativeToolsOnMachine ) {
$env:NativeToolsOnMachine = $true
}
2019-10-24 22:05:36 +00:00
if ( $restore ) {
2019-05-02 12:26:55 +00:00
InitializeNativeTools
}
2018-12-19 20:55:42 +00:00
Build
2018-10-22 05:07:26 +00:00
}
catch {
Write-Host $_ . ScriptStackTrace
2019-11-22 13:41:58 +00:00
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_
2018-10-22 05:07:26 +00:00
ExitWithExitCode 1
}
2018-12-19 20:55:42 +00:00
ExitWithExitCode 0