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

dotnet run command should set DOTNET_ROOT environment variable #9866

Closed
dsplaisted opened this issue Oct 18, 2018 · 7 comments
Closed

dotnet run command should set DOTNET_ROOT environment variable #9866

dsplaisted opened this issue Oct 18, 2018 · 7 comments
Milestone

Comments

@dsplaisted
Copy link
Member

#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.

FYI @natemcmaster @peterhuene

@peterhuene
Copy link
Contributor

peterhuene commented Oct 18, 2018

I'm trying to envision scenarios that break if we always set DOTNET_ROOT (if not already set) from dotnet run.

I need a refresher on the fallback logic that happens when DOTNET_ROOT is set.

Is it an additional probing location or an authoritative one?

That is to say, if I have a 2.1 runtime installed globally, download a 3.0 SDK to a non-default location to use it to build and run a 2.1 targeting app, will dotnet run setting DOTNET_ROOT break the running of the app despite a compatible runtime being present?

@nguerrera
Copy link
Contributor

So it turns out that on Windows, it will still do the multilevel lookup to the global location as a fallback. On Unix, DOTNET_ROOT would just be a complete hammer that overrides the global location. The concerns I raised still apply in general. I think dotnet should be able to append its location as a probing path without altering any other probing paths for runtimes. The host does not have this capability today, but we should ask for it again IMHO.

@nguerrera
Copy link
Contributor

Unlike last time in 2.1, we have some time to adjust in 3.0. I would support making dotnet run set DOTNET_ROOT for now and discussing better alternatives. It is not as invasive as setting it for all builds, for example.

@peterhuene
Copy link
Contributor

I'm good with that plan.

@dsplaisted
Copy link
Member Author

Note: This should set DOTNET_ROOT(x86) instead if the version of .NET is x86

@peterhuene
Copy link
Contributor

I'm going to fix this now to get the CLI tests green.

@peterhuene peterhuene self-assigned this Nov 3, 2018
@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 3.0.1xx milestone Jan 31, 2020
@peterhuene peterhuene removed their assignment May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants