@@ -146,9 +146,8 @@ param(
146146
147147 [switch ]$NoBuildRepoTasks ,
148148
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.
152151 [switch ]$ForceCoreMsbuild ,
153152
154153 # Diagnostics
@@ -187,10 +186,6 @@ if ($DumpProcesses -or $CI) {
187186}
188187
189188# Project selection
190- if ($All ) {
191- $MSBuildArguments += ' /p:BuildAllProjects=true'
192- }
193-
194189if ($Projects ) {
195190 if (! [System.IO.Path ]::IsPathRooted($Projects ))
196191 {
@@ -227,20 +222,8 @@ if ($BuildManaged -or ($All -and (-not $NoBuildManaged))) {
227222 }
228223}
229224
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-
236225if ($NoBuildDeps ) { $MSBuildArguments += " /p:BuildProjectReferences=false" }
237226
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-
244227$RunBuild = if ($NoBuild ) { $false } else { $true }
245228
246229# Run restore by default unless -NoRestore is set.
@@ -276,6 +259,30 @@ if ($DotNetRuntimeSourceFeed -or $DotNetRuntimeSourceFeedKey) {
276259 $ToolsetBuildArguments += $runtimeFeedKeyArg
277260}
278261
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+
279286$foundJdk = $false
280287$javac = Get-Command javac - ErrorAction Ignore - CommandType Application
281288$localJdkPath = " $PSScriptRoot \.tools\jdk\win-x64\"
@@ -343,9 +350,8 @@ $env:MSBUILDDISABLENODEREUSE=1
343350# Fixing this is tracked by https://github.com/dotnet/aspnetcore-internal/issues/601
344351$warnAsError = $false
345352
346- if ($ForceCoreMsbuild ) {
347- $msbuildEngine = ' dotnet'
348- }
353+ # Use `dotnet msbuild` by default
354+ $msbuildEngine = ' dotnet'
349355
350356# Ensure passing neither -bl nor -nobl on CI avoids errors in tools.ps1. This is needed because both parameters are
351357# $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
367373if ($BinaryLog ) {
368374 $bl = GetMSBuildBinaryLogCommandLineArgument($MSBuildArguments )
369375 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" )
371386 }
372387} elseif ($CI ) {
373388 # Ensure the artifacts/log directory isn't empty to avoid warnings.
@@ -394,6 +409,8 @@ try {
394409 }
395410
396411 if (-not $NoBuildRepoTasks ) {
412+ Write-Host
413+
397414 MSBuild $toolsetBuildProj `
398415 / p:RepoRoot= $RepoRoot `
399416 / p:Projects= $EngRoot \tools\RepoTasks\RepoTasks.csproj `
@@ -404,9 +421,21 @@ try {
404421 @ToolsetBuildArguments
405422 }
406423
407- MSBuild $toolsetBuildProj `
408- / p:RepoRoot= $RepoRoot `
409- @MSBuildArguments
424+ if (-not $ForceCoreMsbuild ) {
425+ Write-Host
426+ Remove-Item variable:global:_BuildTool - ErrorAction Ignore
427+ $msbuildEngine = ' vs'
428+
429+ MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @MSBuildArguments
430+ }
431+
432+ if ($performDotnetBuild ) {
433+ Write-Host
434+ Remove-Item variable:global:_BuildTool - ErrorAction Ignore
435+ $msbuildEngine = ' dotnet'
436+
437+ MSBuild $toolsetBuildProj / p:RepoRoot= $RepoRoot @dotnetBuildArguments
438+ }
410439}
411440catch {
412441 Write-Host $_.ScriptStackTrace
0 commit comments