From 95711fa90910997c01c240ad2e36c793ea8491bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Jun 2026 16:12:19 +0000 Subject: [PATCH 1/3] Initial plan From 4a70bedc52884aa0361648c21f97dabd2cbe68eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Jun 2026 16:15:32 +0000 Subject: [PATCH 2/3] Default desktop MSBuild to process-arch (amd64/arm64) binary --- eng/common/tools.ps1 | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index de32a6da377..c8e3dd7f304 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -432,11 +432,33 @@ function InitializeVisualStudioMSBuild([object]$vsRequirements = $null) { $msbuildVersionDir = if ([int]$vsMajorVersion -lt 16) { "$vsMajorVersion.0" } else { "Current" } $local:BinFolder = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin" - $local:Prefer64bit = if (Get-Member -InputObject $vsRequirements -Name 'Prefer64bit') { $vsRequirements.Prefer64bit } else { $false } - if ($local:Prefer64bit -and (Test-Path(Join-Path $local:BinFolder "amd64"))) { - $global:_MSBuildExe = Join-Path $local:BinFolder "amd64\msbuild.exe" - } else { - $global:_MSBuildExe = Join-Path $local:BinFolder "msbuild.exe" + + # By default, use the MSBuild matching the host's process architecture (e.g. amd64 or arm64), + # falling back to the 32-bit MSBuild in the root Bin folder when no matching subfolder exists. + # The 'Prefer64bit' opt-out can be set to false to force the 32-bit MSBuild. + $local:Prefer64bit = if (Get-Member -InputObject $vsRequirements -Name 'Prefer64bit') { $vsRequirements.Prefer64bit } else { $true } + + # Determine the architecture of the current process, accounting for a 32-bit process + # running on a 64-bit OS (PROCESSOR_ARCHITEW6432 holds the real machine architecture). + $local:ProcessArchitecture = $env:PROCESSOR_ARCHITECTURE + if (($local:ProcessArchitecture -eq 'x86') -and ($env:PROCESSOR_ARCHITEW6432)) { + $local:ProcessArchitecture = $env:PROCESSOR_ARCHITEW6432 + } + + # Map the architecture to the corresponding MSBuild subfolder. The 32-bit MSBuild lives in the + # root Bin folder, so x86 maps to an empty subfolder. + $local:MSBuildArchSubFolder = switch ($local:ProcessArchitecture) { + 'AMD64' { 'amd64' } + 'ARM64' { 'arm64' } + default { '' } + } + + $global:_MSBuildExe = Join-Path $local:BinFolder "msbuild.exe" + if ($local:Prefer64bit -and $local:MSBuildArchSubFolder) { + $local:ArchMSBuildExe = Join-Path $local:BinFolder (Join-Path $local:MSBuildArchSubFolder "msbuild.exe") + if (Test-Path $local:ArchMSBuildExe) { + $global:_MSBuildExe = $local:ArchMSBuildExe + } } return $global:_MSBuildExe From a45b70ca37a86d9caafb77e42b5302e00bcbcc27 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Jun 2026 16:19:33 +0000 Subject: [PATCH 3/3] Remove Prefer64bit switch; always select arch-appropriate MSBuild --- eng/common/tools.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index c8e3dd7f304..32bbd183552 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -433,10 +433,8 @@ function InitializeVisualStudioMSBuild([object]$vsRequirements = $null) { $local:BinFolder = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin" - # By default, use the MSBuild matching the host's process architecture (e.g. amd64 or arm64), + # Use the MSBuild matching the host's process architecture (e.g. amd64 or arm64), # falling back to the 32-bit MSBuild in the root Bin folder when no matching subfolder exists. - # The 'Prefer64bit' opt-out can be set to false to force the 32-bit MSBuild. - $local:Prefer64bit = if (Get-Member -InputObject $vsRequirements -Name 'Prefer64bit') { $vsRequirements.Prefer64bit } else { $true } # Determine the architecture of the current process, accounting for a 32-bit process # running on a 64-bit OS (PROCESSOR_ARCHITEW6432 holds the real machine architecture). @@ -454,7 +452,7 @@ function InitializeVisualStudioMSBuild([object]$vsRequirements = $null) { } $global:_MSBuildExe = Join-Path $local:BinFolder "msbuild.exe" - if ($local:Prefer64bit -and $local:MSBuildArchSubFolder) { + if ($local:MSBuildArchSubFolder) { $local:ArchMSBuildExe = Join-Path $local:BinFolder (Join-Path $local:MSBuildArchSubFolder "msbuild.exe") if (Test-Path $local:ArchMSBuildExe) { $global:_MSBuildExe = $local:ArchMSBuildExe