@@ -146,9 +146,8 @@ param(
146
146
147
147
[switch ]$NoBuildRepoTasks ,
148
148
149
- # By default, Windows builds will use MSBuild.exe. Passing this will force the build to run on
150
- # dotnet.exe instead, which may cause issues if you invoke build on a project unsupported by
151
- # MSBuild for .NET Core
149
+ # Disable pre-build of C++ code in x64 (default) and x86 builds. Affects -All and -Projects handling and causes
150
+ # -BuildInstallers and -BuildNative to be ignored.
152
151
[switch ]$ForceCoreMsbuild ,
153
152
154
153
# Diagnostics
@@ -187,10 +186,6 @@ if ($DumpProcesses -or $CI) {
187
186
}
188
187
189
188
# Project selection
190
- if ($All ) {
191
- $MSBuildArguments += ' /p:BuildAllProjects=true'
192
- }
193
-
194
189
if ($Projects ) {
195
190
if (! [System.IO.Path ]::IsPathRooted($Projects ))
196
191
{
@@ -227,20 +222,8 @@ if ($BuildManaged -or ($All -and (-not $NoBuildManaged))) {
227
222
}
228
223
}
229
224
230
- if ($BuildInstallers ) { $MSBuildArguments += " /p:BuildInstallers=true" }
231
- if ($BuildManaged ) { $MSBuildArguments += " /p:BuildManaged=true" }
232
- if ($BuildNative ) { $MSBuildArguments += " /p:BuildNative=true" }
233
- if ($BuildNodeJS ) { $MSBuildArguments += " /p:BuildNodeJS=true" }
234
- if ($BuildJava ) { $MSBuildArguments += " /p:BuildJava=true" }
235
-
236
225
if ($NoBuildDeps ) { $MSBuildArguments += " /p:BuildProjectReferences=false" }
237
226
238
- if ($NoBuildInstallers ) { $MSBuildArguments += " /p:BuildInstallers=false" }
239
- if ($NoBuildManaged ) { $MSBuildArguments += " /p:BuildManaged=false" }
240
- if ($NoBuildNative ) { $MSBuildArguments += " /p:BuildNative=false" }
241
- if ($NoBuildNodeJS ) { $MSBuildArguments += " /p:BuildNodeJS=false" }
242
- if ($NoBuildJava ) { $MSBuildArguments += " /p:BuildJava=false" }
243
-
244
227
$RunBuild = if ($NoBuild ) { $false } else { $true }
245
228
246
229
# Run restore by default unless -NoRestore is set.
@@ -276,6 +259,30 @@ if ($DotNetRuntimeSourceFeed -or $DotNetRuntimeSourceFeedKey) {
276
259
$ToolsetBuildArguments += $runtimeFeedKeyArg
277
260
}
278
261
262
+ # Split build categories between dotnet msbuild and desktop msbuild. Use desktop msbuild as little as possible.
263
+ [string []]$dotnetBuildArguments = $MSBuildArguments
264
+ if ($All ) { $dotnetBuildArguments += ' /p:BuildAllProjects=true' ; $BuildNative = $true }
265
+
266
+ if ($NoBuildInstallers ) { $MSBuildArguments += " /p:BuildInstallers=false" ; $BuildInstallers = $false }
267
+ if ($BuildInstallers ) { $MSBuildArguments += " /p:BuildInstallers=true" }
268
+ if ($NoBuildNative ) { $MSBuildArguments += " /p:BuildNative=false" ; $BuildNative = $false }
269
+ if ($BuildNative ) { $MSBuildArguments += " /p:BuildNative=true" }
270
+
271
+ if ($NoBuildJava ) { $dotnetBuildArguments += " /p:BuildJava=false" ; $BuildJava = $false }
272
+ if ($BuildJava ) { $dotnetBuildArguments += " /p:BuildJava=true" }
273
+ if ($NoBuildManaged ) { $dotnetBuildArguments += " /p:BuildManaged=false" ; $BuildManaged = $false }
274
+ if ($BuildManaged ) { $dotnetBuildArguments += " /p:BuildManaged=true" }
275
+ if ($NoBuildNodeJS ) { $dotnetBuildArguments += " /p:BuildNodeJS=false" ; $BuildNodeJS = $false }
276
+ if ($BuildNodeJS ) { $dotnetBuildArguments += " /p:BuildNodeJS=true" }
277
+
278
+ # Don't bother with two builds if just one will build everything. Ignore super-weird cases like
279
+ # "-Projects ... -NoBuildJava -NoBuildManaged -NoBuildNodeJS".
280
+ $ForceCoreMsbuild = $ForceCoreMsbuild -or -not ($BuildInstallers -or $BuildNative ) -or `
281
+ $Architecture.StartsWith (" arm" , [System.StringComparison ]::OrdinalIgnoreCase)
282
+ $performDotnetBuild = $ForceCoreMsbuild -or $BuildJava -or $BuildManaged -or $BuildNodeJS -or `
283
+ ($All -and -not ($NoBuildJava -and $NoBuildManaged -and $NoBuildNodeJS )) -or `
284
+ ($Projects -and -not ($BuildInstallers -or $BuildNative ))
285
+
279
286
$foundJdk = $false
280
287
$javac = Get-Command javac - ErrorAction Ignore - CommandType Application
281
288
$localJdkPath = " $PSScriptRoot \.tools\jdk\win-x64\"
@@ -343,9 +350,8 @@ $env:MSBUILDDISABLENODEREUSE=1
343
350
# Fixing this is tracked by https://github.com/dotnet/aspnetcore-internal/issues/601
344
351
$warnAsError = $false
345
352
346
- if ($ForceCoreMsbuild ) {
347
- $msbuildEngine = ' dotnet'
348
- }
353
+ # Use `dotnet msbuild` by default
354
+ $msbuildEngine = ' dotnet'
349
355
350
356
# Ensure passing neither -bl nor -nobl on CI avoids errors in tools.ps1. This is needed because both parameters are
351
357
# $false by default i.e. they always exist. (We currently avoid binary logs but that is made visible in the YAML.)
@@ -367,7 +373,16 @@ Remove-Item variable:global:_MSBuildExe -ea Ignore
367
373
if ($BinaryLog ) {
368
374
$bl = GetMSBuildBinaryLogCommandLineArgument($MSBuildArguments )
369
375
if (-not $bl ) {
370
- $MSBuildArguments += " /bl:" + (Join-Path $LogDir " Build.binlog" )
376
+ $dotnetBuildArguments += " /bl:" + (Join-Path $LogDir " Build.binlog" )
377
+ $MSBuildArguments += " /bl:" + (Join-Path $LogDir " Build.native.binlog" )
378
+ $ToolsetBuildArguments += " /bl:" + (Join-Path $LogDir " Build.repotasks.binlog" )
379
+ } else {
380
+ # Use a different binary log path when running desktop msbuild if doing both builds.
381
+ if (-not $ForceCoreMsbuild -and $performDotnetBuild ) {
382
+ $MSBuildArguments += [System.IO.Path ]::ChangeExtension($bl , " native.binlog" )
383
+ }
384
+
385
+ $ToolsetBuildArguments += [System.IO.Path ]::ChangeExtension($bl , " repotasks.binlog" )
371
386
}
372
387
}
373
388
@@ -391,6 +406,8 @@ try {
391
406
}
392
407
393
408
if (-not $NoBuildRepoTasks ) {
409
+ Write-Host
410
+
394
411
MSBuild $toolsetBuildProj `
395
412
/ p:RepoRoot= $RepoRoot `
396
413
/ p:Projects= $EngRoot \tools\RepoTasks\RepoTasks.csproj `
@@ -401,9 +418,21 @@ try {
401
418
@ToolsetBuildArguments
402
419
}
403
420
404
- MSBuild $toolsetBuildProj `
405
- / p:RepoRoot= $RepoRoot `
406
- @MSBuildArguments
421
+ if (-not $ForceCoreMsbuild ) {
422
+ Write-Host
423
+ Remove-Item variable:global:_BuildTool
424
+ $msbuildEngine = ' vs'
425
+
426
+ MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @MSBuildArguments
427
+ }
428
+
429
+ if ($performDotnetBuild ) {
430
+ Write-Host
431
+ Remove-Item variable:global:_BuildTool
432
+ $msbuildEngine = ' dotnet'
433
+
434
+ MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @dotnetBuildArguments
435
+ }
407
436
}
408
437
catch {
409
438
Write-Host $_.ScriptStackTrace
0 commit comments