From c14d4269096f33ac383546b2dcac29a2665e6b94 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 12 Jul 2023 14:18:16 -0700 Subject: [PATCH] Do not consider DOTNET_ROOT when finding dotnet 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`. https://github.com/dotnet/runtime/issues/88754 --- src/Compilers/Shared/RuntimeHostInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compilers/Shared/RuntimeHostInfo.cs b/src/Compilers/Shared/RuntimeHostInfo.cs index 9b53f2c230351..70be40e5f43df 100644 --- a/src/Compilers/Shared/RuntimeHostInfo.cs +++ b/src/Compilers/Shared/RuntimeHostInfo.cs @@ -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". /// + /// + /// See the following issue for rationale why only %PATH% is considered + /// https://github.com/dotnet/runtime/issues/88754 + /// 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))