2019-01-18 10:07:17 -08:00
[ CmdletBinding ( PositionalBinding = $false ) ]
Param (
2019-11-22 13:41:58 +00:00
[ string ] $configuration = 'Debug' ,
2019-02-05 13:42:55 +00:00
[ string ] $task ,
2019-11-22 13:41:58 +00:00
[ string ] $verbosity = 'minimal' ,
2019-01-18 10:07:17 -08:00
[ string ] $msbuildEngine = $null ,
2019-02-05 13:42:55 +00:00
[ switch ] $restore ,
2019-01-18 10:07:17 -08:00
[ switch ] $prepareMachine ,
[ switch ] $help ,
[ Parameter ( ValueFromRemainingArguments = $true ) ] [ String[] ] $properties
)
2019-02-05 13:42:55 +00:00
$ci = $true
$binaryLog = $true
$warnAsError = $true
2019-01-18 10:07:17 -08:00
. $PSScriptRoot \ tools . ps1
function Print-Usage ( ) {
2019-02-05 13:42:55 +00:00
Write-Host " Common settings: "
Write-Host " -task <value> Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package) "
Write-Host " -restore Restore dependencies "
Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] "
Write-Host " -help Print help and exit "
Write-Host " "
2019-01-18 10:07:17 -08:00
2019-02-05 13:42:55 +00:00
Write-Host " Advanced settings: "
Write-Host " -prepareMachine Prepare machine for CI run "
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified). "
Write-Host " "
Write-Host " Command line arguments not listed above are passed thru to msbuild. "
2019-01-18 10:07:17 -08:00
}
2019-02-05 13:42:55 +00:00
function Build([string]$target ) {
2019-11-22 13:41:58 +00:00
$logSuffix = if ( $target -eq 'Execute' ) { '' } else { " . $target " }
2019-02-05 13:42:55 +00:00
$log = Join-Path $LogDir " $task $logSuffix .binlog "
2021-06-12 12:58:31 +00:00
$outputPath = Join-Path $ToolsetDir " $task \ "
2019-01-18 10:07:17 -08:00
2019-02-05 13:42:55 +00:00
MSBuild $taskProject `
/ bl : $log `
/ t: $target `
/ p: Configuration = $configuration `
2019-01-18 10:07:17 -08:00
/ p: RepoRoot = $RepoRoot `
2019-02-05 13:42:55 +00:00
/ p: BaseIntermediateOutputPath = $outputPath `
2020-08-13 14:59:59 +00:00
/ v: $verbosity `
2019-01-18 10:07:17 -08:00
@properties
}
try {
2019-11-22 13:41:58 +00:00
if ( $help -or ( ( $null -ne $properties ) -and ( $properties . Contains ( '/help' ) -or $properties . Contains ( '/?' ) ) ) ) {
2019-01-18 10:07:17 -08:00
Print-Usage
exit 0
}
2019-02-05 13:42:55 +00:00
if ( $task -eq " " ) {
2021-05-26 12:56:24 +00:00
Write-PipelineTelemetryError -Category 'Build' -Message " Missing required parameter '-task <value>' "
2019-01-18 10:07:17 -08:00
Print-Usage
ExitWithExitCode 1
}
2020-04-24 10:34:25 -07:00
if ( $msbuildEngine -eq " vs " ) {
# Ensure desktop MSBuild is available for sdk tasks.
2020-05-08 12:56:55 +00:00
if ( -not ( $GlobalJson . tools . PSObject . Properties . Name -contains " vs " ) ) {
$GlobalJson . tools | Add-Member -Name " vs " -Value ( ConvertFrom-Json " { `" version `" : `" 16.5 `" } " ) -MemberType NoteProperty
2020-04-24 10:34:25 -07:00
}
if ( -not ( $GlobalJson . tools . PSObject . Properties . Name -match " xcopy-msbuild " ) ) {
2022-11-24 13:28:07 +00:00
$GlobalJson . tools | Add-Member -Name " xcopy-msbuild " -Value " 17.4.1 " -MemberType NoteProperty
2020-04-24 10:34:25 -07:00
}
2020-06-02 12:45:27 +00:00
if ( $GlobalJson . tools . " xcopy-msbuild " . Trim ( ) -ine " none " ) {
$xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson . tools . " xcopy-msbuild " -install $true
}
if ( $xcopyMSBuildToolsFolder -eq $null ) {
throw 'Unable to get xcopy downloadable version of msbuild'
}
2020-04-24 10:34:25 -07:00
2020-05-08 12:56:55 +00:00
$global:_MSBuildExe = " $( $xcopyMSBuildToolsFolder ) \MSBuild\Current\Bin\MSBuild.exe "
2020-04-24 10:34:25 -07:00
}
2019-02-05 13:42:55 +00:00
$taskProject = GetSdkTaskProject $task
if ( ! ( Test-Path $taskProject ) ) {
2021-05-26 12:56:24 +00:00
Write-PipelineTelemetryError -Category 'Build' -Message " Unknown task: $task "
2019-02-05 13:42:55 +00:00
ExitWithExitCode 1
}
if ( $restore ) {
2019-11-22 13:41:58 +00:00
Build 'Restore'
2019-01-18 10:07:17 -08:00
}
2019-11-22 13:41:58 +00:00
Build 'Execute'
2019-01-18 10:07:17 -08:00
}
catch {
Write-Host $_ . ScriptStackTrace
2019-11-22 13:41:58 +00:00
Write-PipelineTelemetryError -Category 'Build' -Message $_
2019-01-18 10:07:17 -08:00
ExitWithExitCode 1
}
ExitWithExitCode 0