-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Set DOTNET_ROOT from the CLI to ensure any child processes launched use same root #9192
Conversation
…se the same install location of dotnet
@natemcmaster are you going to take this change to shiproom for approval? |
Please, fill out the ask mode template and tag matt for M2 approval. After which point we can take it to shiproom. You can see the ask mode template here: #9160. |
Yes. I'll send in a few minutes. |
I think we agreed NOT to do this. cc @richlander @steveharter |
@nguerrera @dsplaisted we need carefully consider this change. This will alter the behavior of future selfcontain |
try | ||
{ | ||
var rootPath = Path.GetDirectoryName(new Muxer().MuxerPath); | ||
env.SetEnvironmentVariable(dotnetRootEnv, rootPath, EnvironmentVariableTarget.Process); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should do this.
@wli3 Can you explain? Why would self-contained apps need to look at DOTNET_ROOT at all?
So you're saying you want to support a scenario where the .NET Core SDK can launch tools using runtimes from different folder, not next tot the SDK. How common is this scenario? Has this every worked before 2.1.300? My guess is this is less common than users who want to invoke
Hasn't this already been solved via multi-level lookup? Or does DOTNET_ROOT imply DOTNET_MULTILEVEL_LOOKUP=0?
It's a new feature, right? so this can't break customers who have only used stable tooling. IMO it's already a broken feature. I'm just trying to help by pointing out that the current design is broken for common scenarios. |
catch | ||
{ | ||
// swallow and ignore in the event MuxerPath throws because it cannot find dotnet.exe | ||
return; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This seems to imply more power than DOTNET_ROOT actually has. It is used only by apphost for activation of framework-dependent executables.
This is a case where we absolutely do want to control the runtime, but we don't run these as framework-dependent exes, so DOTNET_ROOT does not apply. Just tried I have commented before that I don't believe we should ever bundle framework-dependent exes with the CLI.
Only for
I'm double checking this now, but I don't believe multi-level lookup has any impact on apphost activation of framework dependent exes. (EDIT: I was wrong here, but multi-level lookup currently only works on Windows.) |
I wasn't talking about breaking changes in that sense. I meant: if this behavior is not what I want, how do I opt out of it? |
The sub-processes of the SDK have always been open-ended. MSBuild is arbitrarily extensible. This change is asserting that the correct runtime for any framework-dependent .exe launched anywhere in the process subtree of a CLI command must be the same as the CLI runtime. I don't think this will hold always. Let's say we have |
@nguerrera would you be more inclined to support this PR if:
|
@peterhuene Those would make me slightly happier, but I think we need to think about this carefully and find the right solution at the right layer. For example, a nicer solution would be if we could append ourselves to a |
It doesn't sound like this is going to get shiproom approval so we'll just have to live with the current behavior. |
Partial solution to https://github.com/dotnet/cli/issues/9114.
This sets DOTNET_ROOT (or DOTNET_ROOT(x86)) at the beginning of the dotnet.dll process. This should help ensure any child processes launched by the SDK via apphost will run on the same installation of .NET Core as the dotnet SDK. These child processes may include
dotnet run
, bundled tools, global tools, processes launched through MSBuild, and more.