Skip to content

Commit

Permalink
Do not consider DOTNET_ROOT when finding dotnet
Browse files Browse the repository at this point in the history
This changes our `dotnet` launch code to not consider `$DOTNET_ROOT` as
that is a apphost specific variable.

After discussion with the runtime team determined that only `$PATH` will
be considered for finding `dotnet`.

dotnet/runtime#88754
  • Loading branch information
Jared Parsons committed Jul 12, 2023
1 parent d71ec68 commit c14d426
Showing 1 changed file with 4 additions and 4 deletions.
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
/// </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

0 comments on commit c14d426

Please sign in to comment.