Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not consider DOTNET_ROOT when finding dotnet #69010

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Compilers/Shared/RuntimeHostInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ internal static (string processFilePath, string commandLineArguments, string too
/// Get the path to the dotnet executable. In the case the host did not provide this information
/// in the environment this will return simply "dotnet".
/// </summary>
/// <remarks>
/// See the following issue for rationale why only %PATH% is considered
/// https://github.com/dotnet/runtime/issues/88754
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd honestly prefer the docs link here, that was far clearer than this thread 🙂

/// </remarks>
internal static string GetDotNetPathOrDefault()
{
var (fileName, sep) = PlatformInformation.IsWindows
? ("dotnet.exe", ';')
: ("dotnet", ':');
if (Environment.GetEnvironmentVariable("DOTNET_ROOT") is { } rootStr)
{
return Path.Combine(rootStr, fileName);
}

var path = Environment.GetEnvironmentVariable("PATH") ?? "";
foreach (var item in path.Split(sep, StringSplitOptions.RemoveEmptyEntries))
Expand Down