Skip to content

Commit

Permalink
DOTNET_ROOT is a folder. Also, DOTNET_ROOT(x86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Forgind committed Aug 9, 2023
1 parent e146ad8 commit 59c2d52
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/MSBuildLocator/DotNetSdkLocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,24 @@ private static IEnumerable<string> GetDotNetBasePaths(string workingDirectory)
string dotnet_root = Environment.GetEnvironmentVariable("DOTNET_ROOT");
if (!string.IsNullOrEmpty(dotnet_root))
{
// DOTNET_ROOT can be a path to dotnet OR a path to the folder containing dotnet.
string fullPathToDotnetFromRoot = Path.Combine(dotnet_root, exeName);
if (File.Exists(fullPathToDotnetFromRoot))
{
dotnetPath = fullPathToDotnetFromRoot;
}
else if (File.Exists(dotnet_root))
}

// Second, check for the DOTNET_ROOT(x86) environment variable, as it can be there, too.
if (dotnetPath is null)
{
string dotnet_root_x86 = Environment.GetEnvironmentVariable("DOTNET_ROOT(x86)");
if (!string.IsNullOrEmpty(dotnet_root_x86))
{
dotnetPath = dotnet_root;
string fullPathToDotnetFromRoot = Path.Combine(dotnet_root_x86, exeName);
if (File.Exists(fullPathToDotnetFromRoot))
{
dotnetPath = fullPathToDotnetFromRoot;
}
}
}

Expand Down

0 comments on commit 59c2d52

Please sign in to comment.