-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fill in gaps in shared runtime location logic (DOTNET_ROOT) #38462
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar |
And is We are not doing anything with |
It is not set. |
I talked to @tmat yesterday about this and encouraged him to create this issue to allow for a broader conversation. I think of this as the general problem where people use the product with non-standard install locations (private installs are the best example). Perhaps, all we need to do is write better docs to get people to set We had a whole series of conversation on this, and I remember much of that detail. We came to the existing I think missing an API that gives you the value you need for I think of this as similar to the space of multi-level lookup (MLL). I both appreciate and am frustrated by that feature. This is what proposal 1 is about. The idea is that you start with a fully qualified path to the |
Do you mean API that gives you the value you need for |
I mean one that would give the value you need for From @tmat: That isn't the currency required for |
I am not sure we want to be encouraging editing
+1 |
The issue seem very similar to dotnet/install-scripts#43 and dotnet/install-scripts#47 - as private installs are typically created via the install scripts. |
That's where I've been aware for some time that this is a soft spot for us. I'm most interesting in the ad-hoc dev environments, but CI aligns well. Are you compelled by that approach, @tmat? |
We might just need a better documentation. The test project in the above scenario was targeting I switched the test project to |
Is 3.1 installed globally on this machine? set |
It may or may not be. It's a CI machine. We want the tests to use the exact dotnet that invoked the test runner. |
https://github.com/dotnet/roslyn/blob/master/eng/common/tools.ps1#L105 |
Does it pick the right runtime (as in - the one from the repo you want)? Ultimately to find out: set |
I take this back. The CI infra had a bug and actually did not run the tests properly. After fixing the issue the test behaves the same as when targeting net472 - that is, the child process fails to find dotnet runtime unless The proposals above are still relevant. The current workaround is: if (Environment.GetEnvironmentVariable("DOTNET_ROOT") == null)
{
var dir = RuntimeEnvironment.GetRuntimeDirectory();
while (dir != null && !File.Exists(Path.Combine(dir, "dotnet.exe")))
{
dir = Path.GetDirectoryName(dir);
}
Environment.SetEnvironmentVariable("DOTNET_ROOT", dir);
} |
Resolving as duplicate of #88754 that has better description of the problem and discussion of the solutions. |
Scenario:
A test project is testing a product.exe built in the same repo.
The project that builds product.exe targets netcoreapp and uses shared framework.
The test uses
Process
APIs to launch product.exe process.When the test runs on a machine that has the matching runtime installed globally, the test works without setting any env variables. However, when the same test runs on another machine that does not have the runtime installed globally it fails with error: "The required library hostfxr.dll could not be found. Exit code -2147450749."
This is because
DOTNET_ROOT
is not set for the child process.Proposals
If the test project targets netcoreapp it would be better to flow the current runtime path to the child process as a fallback runtime by default. This fallback path would only be used as the last resort - before reporting the above error. I believe it would address many common scenarios without the developer needing to change anything.
Since [1] is not currently implemented the test currently needs to set
DOTNET_ROOT
. There doesn't seem to be an API that returns the path to the directory that containsdotnet.exe
. So the ask is to provide an API that can be used to determine the path of the current runtime thatDOTNET_ROOT
would accept.RuntimeEnvironment.GetRuntimeDirectory()
returns path to the shared runtime directory. A workaround then is to find a directory above this directory that containsdotnet.exe
.The text was updated successfully, but these errors were encountered: