dotnet run command should set DOTNET_ROOT environment variable
See original GitHub issue#Repro steps
- Install a local copy of the .NET Core SDK (ie unzip it to a local folder, or install it to a local folder using the dotnet-install script)
- Create a new console app (
dotnet new console
) - Run the app via
dotnet run
Expected
App runs
Actual
Host can’t find the right shared framework (unless a matching shared framework is also installed in the global location, such as Program Files).
Discussion
This is because we now copy the apphost as <appname>.exe
, and dotnet run
uses that apphost. Previously it used dotnet <appname>.dll
, which had the context of where the dotnet root was, but the apphost by itself doesn’t have that context, so it only looks in the globally installed location.
We can fix this by setting the DOTNET_ROOT
environment variable in dotnet run
before launching the app. We could also consider always setting this environment variable, which we considered in the past.
These solutions still won’t help if <appname>.exe
is launched directly instead of via a dotnet
command. In the past we’ve discussed that probing the PATH
from the muxer could help, but so far have decided against it.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top GitHub Comments
Note: This should set
DOTNET_ROOT(x86)
instead if the version of .NET is x86I’m going to fix this now to get the CLI tests green.