From 3c54936203c8622f367af5fdbfc37d30d256b11c Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:25:34 -0700 Subject: [PATCH] Add option to prefer 64bit `msbuild` --- eng/common/tools.ps1 | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 2205c9e8117..085e8a75c57 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -211,12 +211,12 @@ function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $arc InstallDotNet -dotnetRoot $dotnetRoot -version $version -architecture $architecture -skipNonVersionedFiles $false -runtimeSourceFeed $runtimeSourceFeed -runtimeSourceFeedKey $runtimeSourceFeedKey } -function InstallDotNet([string] $dotnetRoot, - [string] $version, - [string] $architecture = "", - [string] $runtime = "", - [bool] $skipNonVersionedFiles = $false, - [string] $runtimeSourceFeed = "", +function InstallDotNet([string] $dotnetRoot, + [string] $version, + [string] $architecture = "", + [string] $runtime = "", + [bool] $skipNonVersionedFiles = $false, + [string] $runtimeSourceFeed = "", [string] $runtimeSourceFeedKey = "") { $installScript = GetDotNetInstallScript $dotnetRoot @@ -323,7 +323,16 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = } $msbuildVersionDir = if ([int]$vsMajorVersion -lt 16) { "$vsMajorVersion.0" } else { "Current" } - return $global:_MSBuildExe = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin\msbuild.exe" + + $local:BinFolder = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin" + $local:Prefer64bit = if ($vsRequirements.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" + } + + return $global:_MSBuildExe } function InitializeVisualStudioEnvironmentVariables([string] $vsInstallDir, [string] $vsMajorVersion) { @@ -523,7 +532,7 @@ function InitializeNativeTools() { } } -function InitializeToolset([string] $runtimeSourceFeed, [string] $runtimeSourceFeedKey) +function InitializeToolset([string] $runtimeSourceFeed, [string] $runtimeSourceFeedKey) { if (Test-Path variable:global:_ToolsetBuildProj) { return $global:_ToolsetBuildProj