Skip to content

Commit

Permalink
Help Standalone MSBuild Find Its Family (#7877)
Browse files Browse the repository at this point in the history
  • Loading branch information
benvillalobos authored Aug 15, 2022
1 parent f67e3d3 commit 2badb37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.3.0</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<VersionPrefix>17.3.1</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>
Expand Down
13 changes: 10 additions & 3 deletions src/Shared/BuildEnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,16 @@ NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorA
{
// In the .NET SDK, there's one copy of MSBuild.dll and it's in the root folder.
MSBuildToolsDirectoryRoot = CurrentMSBuildToolsDirectory;

// If we're standalone, we might not be in the SDK. Rely on folder paths at this point.
if (string.Equals(currentToolsDirectory.Name, "amd64", StringComparison.OrdinalIgnoreCase) ||
string.Equals(currentToolsDirectory.Name, "arm64", StringComparison.OrdinalIgnoreCase))
{
MSBuildToolsDirectoryRoot = currentToolsDirectory.Parent?.FullName;
}
}

if (mode == BuildEnvironmentMode.VisualStudio && MSBuildToolsDirectoryRoot != null)
if (MSBuildToolsDirectoryRoot != null)
{
// Calculate potential paths to other architecture MSBuild.exe
var potentialAmd64FromX86 = FileUtilities.CombinePaths(MSBuildToolsDirectoryRoot, "amd64", msBuildExeName);
Expand All @@ -563,8 +570,8 @@ NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorA
var existsCheck = mode == BuildEnvironmentMode.VisualStudio ? new Func<string, bool>(_ => true) : File.Exists;

MSBuildToolsDirectory32 = MSBuildToolsDirectoryRoot;
MSBuildToolsDirectory64 = Path.Combine(MSBuildToolsDirectoryRoot, "amd64");
MSBuildToolsDirectoryArm64 = File.Exists(potentialARM64FromX86) ? Path.Combine(MSBuildToolsDirectoryRoot, "arm64") : null;
MSBuildToolsDirectory64 = existsCheck(potentialAmd64FromX86) ? Path.Combine(MSBuildToolsDirectoryRoot, "amd64") : CurrentMSBuildToolsDirectory;
MSBuildToolsDirectoryArm64 = existsCheck(potentialARM64FromX86) ? Path.Combine(MSBuildToolsDirectoryRoot, "arm64") : null;
}

MSBuildExtensionsPath = mode == BuildEnvironmentMode.VisualStudio
Expand Down

0 comments on commit 2badb37

Please sign in to comment.