35
35
# Specifies which msbuild engine to use for build: 'vs', 'dotnet' or unspecified (determined based on presence of tools.vs in global.json).
36
36
[string ]$msbuildEngine = if (Test-Path variable:msbuildEngine) { $msbuildEngine } else { $null }
37
37
38
- # True to attempt using .NET Core already that meets requirements specified in global.json
38
+ # True to attempt using .NET Core already that meets requirements specified in global.json
39
39
# installed on the machine instead of downloading one.
40
40
[bool ]$useInstalledDotNetCli = if (Test-Path variable:useInstalledDotNetCli) { $useInstalledDotNetCli } else { $true }
41
41
@@ -76,7 +76,7 @@ function Exec-Process([string]$command, [string]$commandArgs) {
76
76
77
77
$finished = $false
78
78
try {
79
- while (-not $process.WaitForExit (100 )) {
79
+ while (-not $process.WaitForExit (100 )) {
80
80
# Non-blocking loop done to allow ctr-c interrupts
81
81
}
82
82
@@ -250,7 +250,7 @@ function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $archit
250
250
}
251
251
252
252
#
253
- # Locates Visual Studio MSBuild installation.
253
+ # Locates Visual Studio MSBuild installation.
254
254
# The preference order for MSBuild to use is as follows:
255
255
#
256
256
# 1. MSBuild from an active VS command prompt
@@ -267,7 +267,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
267
267
268
268
if (! $vsRequirements ) { $vsRequirements = $GlobalJson.tools.vs }
269
269
$vsMinVersionStr = if ($vsRequirements.version ) { $vsRequirements.version } else { " 15.9" }
270
- $vsMinVersion = [Version ]::new($vsMinVersionStr )
270
+ $vsMinVersion = [Version ]::new($vsMinVersionStr )
271
271
272
272
# Try msbuild command available in the environment.
273
273
if ($env: VSINSTALLDIR -ne $null ) {
@@ -316,7 +316,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
316
316
function InitializeVisualStudioEnvironmentVariables ([string ] $vsInstallDir , [string ] $vsMajorVersion ) {
317
317
$env: VSINSTALLDIR = $vsInstallDir
318
318
Set-Item " env:VS$ ( $vsMajorVersion ) 0COMNTOOLS" (Join-Path $vsInstallDir " Common7\Tools\" )
319
-
319
+
320
320
$vsSdkInstallDir = Join-Path $vsInstallDir " VSSDK\"
321
321
if (Test-Path $vsSdkInstallDir ) {
322
322
Set-Item " env:VSSDK$ ( $vsMajorVersion ) 0Install" $vsSdkInstallDir
@@ -351,13 +351,13 @@ function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) {
351
351
# Locates Visual Studio instance that meets the minimal requirements specified by tools.vs object in global.json.
352
352
#
353
353
# The following properties of tools.vs are recognized:
354
- # "version": "{major}.{minor}"
354
+ # "version": "{major}.{minor}"
355
355
# Two part minimal VS version, e.g. "15.9", "16.0", etc.
356
- # "components": ["componentId1", "componentId2", ...]
356
+ # "components": ["componentId1", "componentId2", ...]
357
357
# Array of ids of workload components that must be available in the VS instance.
358
358
# See e.g. https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-enterprise?view=vs-2017
359
359
#
360
- # Returns JSON describing the located VS instance (same format as returned by vswhere),
360
+ # Returns JSON describing the located VS instance (same format as returned by vswhere),
361
361
# or $null if no instance meeting the requirements is found on the machine.
362
362
#
363
363
function LocateVisualStudio ([object ]$vsRequirements = $null ){
@@ -378,7 +378,7 @@ function LocateVisualStudio([object]$vsRequirements = $null){
378
378
379
379
if (! $vsRequirements ) { $vsRequirements = $GlobalJson.tools.vs }
380
380
$args = @ (" -latest" , " -prerelease" , " -format" , " json" , " -requires" , " Microsoft.Component.MSBuild" )
381
-
381
+
382
382
if (Get-Member - InputObject $vsRequirements - Name " version" ) {
383
383
$args += " -version"
384
384
$args += $vsRequirements.version
@@ -388,7 +388,7 @@ function LocateVisualStudio([object]$vsRequirements = $null){
388
388
foreach ($component in $vsRequirements.components ) {
389
389
$args += " -requires"
390
390
$args += $component
391
- }
391
+ }
392
392
}
393
393
394
394
$vsInfo = & $vsWhereExe $args | ConvertFrom-Json
@@ -445,7 +445,7 @@ function GetDefaultMSBuildEngine() {
445
445
if (Get-Member - InputObject $GlobalJson.tools - Name " vs" ) {
446
446
return " vs"
447
447
}
448
-
448
+
449
449
if (Get-Member - InputObject $GlobalJson.tools - Name " dotnet" ) {
450
450
return " dotnet"
451
451
}
@@ -475,11 +475,13 @@ function GetSdkTaskProject([string]$taskName) {
475
475
476
476
function InitializeNativeTools () {
477
477
if (Get-Member - InputObject $GlobalJson - Name " native-tools" ) {
478
- $nativeArgs = " "
478
+ $nativeArgs = @ {}
479
479
if ($ci ) {
480
- $nativeArgs = " -InstallDirectory $ToolsDir "
480
+ $nativeArgs = @ {
481
+ InstallDirectory = " $ToolsDir "
482
+ }
481
483
}
482
- Invoke-Expression " & ` "$PSScriptRoot /init-tools-native.ps1`" $ nativeArgs"
484
+ & " $PSScriptRoot /init-tools-native.ps1" @ nativeArgs
483
485
}
484
486
}
485
487
@@ -573,38 +575,38 @@ function MSBuild-Core() {
573
575
574
576
$cmdArgs = " $ ( $buildTool.Command ) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci "
575
577
576
- if ($warnAsError ) {
577
- $cmdArgs += " /warnaserror /p:TreatWarningsAsErrors=true"
578
+ if ($warnAsError ) {
579
+ $cmdArgs += " /warnaserror /p:TreatWarningsAsErrors=true"
578
580
}
579
581
580
582
foreach ($arg in $args ) {
581
583
if ($arg -ne $null -and $arg.Trim () -ne " " ) {
582
584
$cmdArgs += " `" $arg `" "
583
585
}
584
586
}
585
-
587
+
586
588
$exitCode = Exec- Process $buildTool.Path $cmdArgs
587
589
588
590
if ($exitCode -ne 0 ) {
589
591
Write-PipelineTaskError " Build failed."
590
592
591
593
$buildLog = GetMSBuildBinaryLogCommandLineArgument $args
592
- if ($buildLog -ne $null ) {
593
- Write-Host " See log: $buildLog " - ForegroundColor DarkGray
594
+ if ($buildLog -ne $null ) {
595
+ Write-Host " See log: $buildLog " - ForegroundColor DarkGray
594
596
}
595
597
596
598
ExitWithExitCode $exitCode
597
599
}
598
600
}
599
601
600
- function GetMSBuildBinaryLogCommandLineArgument ($arguments ) {
602
+ function GetMSBuildBinaryLogCommandLineArgument ($arguments ) {
601
603
foreach ($argument in $arguments ) {
602
604
if ($argument -ne $null ) {
603
605
$arg = $argument.Trim ()
604
606
if ($arg.StartsWith (" /bl:" , " OrdinalIgnoreCase" )) {
605
607
return $arg.Substring (" /bl:" .Length)
606
- }
607
-
608
+ }
609
+
608
610
if ($arg.StartsWith (" /binaryLogger:" , " OrdinalIgnoreCase" )) {
609
611
return $arg.Substring (" /binaryLogger:" .Length)
610
612
}
0 commit comments