[2020-02] Bump msbuild to track mono-2019-12 (#19661)
[mono-project.git] / eng / common / sdk-task.ps1
blob3872af59b9728882c605d4343546fea725cd42a6
1 [CmdletBinding(PositionalBinding=$false)]
2 Param(
3 [string] $configuration = 'Debug',
4 [string] $task,
5 [string] $verbosity = 'minimal',
6 [string] $msbuildEngine = $null,
7 [switch] $restore,
8 [switch] $prepareMachine,
9 [switch] $help,
10 [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
13 $ci = $true
14 $binaryLog = $true
15 $warnAsError = $true
17 . $PSScriptRoot\tools.ps1
19 function Print-Usage() {
20 Write-Host "Common settings:"
21 Write-Host " -task <value> Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)"
22 Write-Host " -restore Restore dependencies"
23 Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]"
24 Write-Host " -help Print help and exit"
25 Write-Host ""
27 Write-Host "Advanced settings:"
28 Write-Host " -prepareMachine Prepare machine for CI run"
29 Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
30 Write-Host ""
31 Write-Host "Command line arguments not listed above are passed thru to msbuild."
34 function Build([string]$target) {
35 $logSuffix = if ($target -eq 'Execute') { '' } else { ".$target" }
36 $log = Join-Path $LogDir "$task$logSuffix.binlog"
37 $outputPath = Join-Path $ToolsetDir "$task\\"
39 MSBuild $taskProject `
40 /bl:$log `
41 /t:$target `
42 /p:Configuration=$configuration `
43 /p:RepoRoot=$RepoRoot `
44 /p:BaseIntermediateOutputPath=$outputPath `
45 @properties
48 try {
49 if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) {
50 Print-Usage
51 exit 0
54 if ($task -eq "") {
55 Write-PipelineTelemetryError -Category 'Build' -Message "Missing required parameter '-task <value>'" -ForegroundColor Red
56 Print-Usage
57 ExitWithExitCode 1
60 $taskProject = GetSdkTaskProject $task
61 if (!(Test-Path $taskProject)) {
62 Write-PipelineTelemetryError -Category 'Build' -Message "Unknown task: $task" -ForegroundColor Red
63 ExitWithExitCode 1
66 if ($restore) {
67 Build 'Restore'
70 Build 'Execute'
72 catch {
73 Write-Host $_.ScriptStackTrace
74 Write-PipelineTelemetryError -Category 'Build' -Message $_
75 ExitWithExitCode 1
78 ExitWithExitCode 0