@@ -184,6 +184,7 @@ param(
184
184
[Alias (' v' )]
185
185
[string ]$Verbosity = ' minimal' ,
186
186
[switch ]$DumpProcesses , # Capture all running processes and dump them to a file.
187
+ [string ]$msbuildEngine = ' dotnet' ,
187
188
188
189
# Other lifecycle targets
189
190
[switch ]$Help , # Show help
@@ -288,24 +289,20 @@ if ($RuntimeSourceFeed -or $RuntimeSourceFeedKey) {
288
289
}
289
290
290
291
# Split build categories between dotnet msbuild and desktop msbuild. Use desktop msbuild as little as possible.
291
- [string []]$dotnetBuildArguments = $MSBuildArguments
292
+ [string []]$dotnetBuildArguments = ' '
293
+ [string []]$MSBuildOnlyArguments = ' '
294
+
292
295
if ($All ) { $dotnetBuildArguments += ' /p:BuildAllProjects=true' }
293
- if ($Projects ) {
294
- if ($BuildNative ) {
295
- $MSBuildArguments += " /p:ProjectToBuild=$Projects "
296
- } else {
297
- $dotnetBuildArguments += " /p:ProjectToBuild=$Projects "
298
- }
299
- }
296
+ if ($Projects ) { $MSBuildArguments += " /p:ProjectToBuild=$Projects " }
300
297
301
- if ($NoBuildInstallers ) { $MSBuildArguments += " /p:BuildInstallers=false" ; $BuildInstallers = $false }
302
- if ($BuildInstallers ) { $MSBuildArguments += " /p:BuildInstallers=true" }
298
+ if ($NoBuildInstallers ) { $MSBuildOnlyArguments += " /p:BuildInstallers=false" ; $BuildInstallers = $false }
299
+ if ($BuildInstallers ) { $MSBuildOnlyArguments += " /p:BuildInstallers=true" }
303
300
304
301
# Build native projects by default unless -NoBuildNative was specified.
305
302
$specifiedBuildNative = $BuildNative
306
303
$BuildNative = $true
307
- if ($NoBuildNative ) { $MSBuildArguments += " /p:BuildNative=false" ; $BuildNative = $false }
308
- if ($BuildNative ) { $MSBuildArguments += " /p:BuildNative=true" }
304
+ if ($NoBuildNative ) { $MSBuildOnlyArguments += " /p:BuildNative=false" ; $BuildNative = $false }
305
+ if ($BuildNative ) { $MSBuildOnlyArguments += " /p:BuildNative=true" }
309
306
310
307
if ($NoBuildJava ) { $dotnetBuildArguments += " /p:BuildJava=false" ; $BuildJava = $false }
311
308
if ($BuildJava ) { $dotnetBuildArguments += " /p:BuildJava=true" }
@@ -317,23 +314,24 @@ if ($BuildNodeJS) { $dotnetBuildArguments += "/p:BuildNodeJSUnlessSourcebuild=tr
317
314
# Don't bother with two builds if just one will build everything. Ignore super-weird cases like
318
315
# "-Projects ... -NoBuildJava -NoBuildManaged -NoBuildNodeJS". An empty `./build.ps1` command will build both
319
316
# managed and native projects.
320
- $performDesktopBuild = $BuildInstallers -or $BuildNative
321
- $performDotnetBuild = $BuildJava -or $BuildManaged -or $BuildNodeJS -or `
317
+
318
+ # If -msbuildEngine vs is explicitly passed in, use desktop msbuild only.
319
+ # This is necessary for one-shot builds like within the VMR.
320
+
321
+ $performDesktopBuild = $BuildInstallers -or $BuildNative -or $msbuildEngine -eq ' vs'
322
+ $performDotnetBuild = $msBuildEngine -ne ' vs' -and ($BuildJava -or $BuildManaged -or $BuildNodeJS -or `
322
323
($All -and -not ($NoBuildJava -and $NoBuildManaged -and $NoBuildNodeJS )) -or `
323
- ($Projects -and -not ($BuildInstallers -or $specifiedBuildNative ))
324
+ ($Projects -and -not ($BuildInstallers -or $specifiedBuildNative )))
324
325
325
326
# Initialize global variables need to be set before the import of Arcade is imported
326
327
$restore = $RunRestore
327
328
328
- # Though VS Code may indicate $nodeReuse and $msbuildEngine are unused, tools.ps1 uses them.
329
+ # Though VS Code may indicate $nodeReuse is unused, tools.ps1 uses them.
329
330
330
331
# Disable node reuse - Workaround perpetual issues in node reuse and custom task assemblies
331
332
$nodeReuse = $false
332
333
$env: MSBUILDDISABLENODEREUSE = 1
333
334
334
- # Use `dotnet msbuild` by default
335
- $msbuildEngine = ' dotnet'
336
-
337
335
# Ensure passing neither -bl nor -nobl on CI avoids errors in tools.ps1. This is needed because both parameters are
338
336
# $false by default i.e. they always exist. (We currently avoid binary logs but that is made visible in the YAML.)
339
337
if ($CI -and -not $excludeCIBinarylog ) {
@@ -414,12 +412,17 @@ if ($BinaryLog) {
414
412
$bl = GetMSBuildBinaryLogCommandLineArgument($MSBuildArguments )
415
413
if (-not $bl ) {
416
414
$dotnetBuildArguments += " /bl:" + (Join-Path $LogDir " Build.binlog" )
417
- $MSBuildArguments += " /bl:" + (Join-Path $LogDir " Build.native.binlog" )
415
+
416
+ # When running both builds, use a different binary log path for the desktop msbuild.
417
+ if ($performDesktopBuild -and $performDotnetBuild ) {
418
+ $MSBuildOnlyArguments += " /bl:" + (Join-Path $LogDir " Build.native.binlog" )
419
+ }
420
+
418
421
$ToolsetBuildArguments += " /bl:" + (Join-Path $LogDir " Build.repotasks.binlog" )
419
422
} else {
420
423
# Use a different binary log path when running desktop msbuild if doing both builds.
421
424
if ($performDesktopBuild -and $performDotnetBuild ) {
422
- $MSBuildArguments += " /bl:" + [System.IO.Path ]::ChangeExtension($bl , " native.binlog" )
425
+ $MSBuildOnlyArguments += " /bl:" + [System.IO.Path ]::ChangeExtension($bl , " native.binlog" )
423
426
}
424
427
425
428
$ToolsetBuildArguments += " /bl:" + [System.IO.Path ]::ChangeExtension($bl , " repotasks.binlog" )
@@ -478,15 +481,20 @@ try {
478
481
Remove-Item variable:global:_BuildTool - ErrorAction Ignore
479
482
$msbuildEngine = ' vs'
480
483
481
- MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @MSBuildArguments
484
+ # When running with desktop msbuild only, append the dotnet build specific arguments.
485
+ if (-not $performDotnetBuild ) {
486
+ $MSBuildOnlyArguments += $dotnetBuildArguments
487
+ }
488
+
489
+ MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @MSBuildArguments @MSBuildOnlyArguments
482
490
}
483
491
484
492
if ($performDotnetBuild ) {
485
493
Write-Host
486
494
Remove-Item variable:global:_BuildTool - ErrorAction Ignore
487
495
$msbuildEngine = ' dotnet'
488
496
489
- MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @dotnetBuildArguments
497
+ MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @MSBuildArguments @ dotnetBuildArguments
490
498
}
491
499
}
492
500
}
0 commit comments