Skip to content

Commit

Permalink
Avoid potential NRE (#29128)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat authored and marcpopMSFT committed Nov 18, 2022
1 parent 19ebb6c commit 6bc8daf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,12 @@ private void ConfigureExecutable(DotNetWatchContext context, ProcessSpec process
processSpec.EnvironmentVariables["ASPNETCORE_URLS"] = context.LaunchSettingsProfile.ApplicationUrl;
}

var rootVariableName = Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)";
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(rootVariableName)))
var rootVariableName = EnvironmentVariableNames.TryGetDotNetRootVariableName(
project.RuntimeIdentifier ?? "",
project.DefaultAppHostRuntimeIdentifier ?? "",
project.TargetFrameworkVersion);

if (rootVariableName != null && string.IsNullOrEmpty(Environment.GetEnvironmentVariable(rootVariableName)))
{
processSpec.EnvironmentVariables[rootVariableName] = Path.GetDirectoryName(_muxerPath);
}
Expand Down

0 comments on commit 6bc8daf

Please sign in to comment.