-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
FDD app uses DOTNET_ROOT even though it points to wrong architecture #68180
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsDescriptionnethost returns location of 64-bit hostfxr.dll to 32-bit process. Reproduction StepsI have a custom native host that uses nethost to locate hostfxr.dll. I'm running into a problem when testing this native host inside of Xunit tests from "dotnet test". "dotnet test" is 64-bit and is setting DOTNET_ROOT to "C:\Program Files\dotnet". This environment variable is propagating all the way to the testhost.exe process. In my test, I'm calling Expected behaviorIgnore DOTNET_ROOT since it is the wrong architecture. Actual behaviorTrusts DOTNET_ROOT is correct. Regression?Yes. The issue seems to be from #53763. Before that change, x86 nethost would never have used DOTNET_ROOT, only DOTNET_ROOT(x86). Known WorkaroundsIn my case, I can workaround this by using Configuration
Other informationNo response
|
As you linked, this is by-design. Since you already have your own custom host, could you simply clear the DOTNET_ROOT environment variable and proceed with your custom dotnet location? Otherwise, it sounds like |
This is not true. I would like my custom host to support standard functionality. What I want is for the nethost logic to be able to reject locations with the wrong architecture.
I don't have a custom dotnet location. I need nethost to give me the standard path.
I might have to do this, but as I mentioned above that is removing standard functionality so I would rather not.
Why would there be a configuration switch? As you said, they are simply passing the wrong variable. The problem is that this was a breaking change and |
Maybe I'm not understanding the scenario fully. It sounds like |
Thanks for reporting this @rseanhall! The change in #53763 caused the The x64 I still believe the design of #53673 was correct - as it makes the behavior of We should fix I don't think the host should try to detect if the As for Fixing @MarcoRossignoli @pavelhorak for |
The test project is 64-bit. The tests run both 32-bit and 64-bit versions of the custom host. The test project needs to be 64-bit so it can easily access 64-bit files and registry keys.
This is not the first time that |
Thanks for the scenario description @rseanhall. In your case, if your tests are actually spawning a child process, I would consider simply cleaning the environment for these child processes. Or have a different mechanism how to specify which runtime they should use. (That's not to say that |
Can we tweak the fallback behavior so that DOTNET_ROOT is used last? Meaning that the order would be:
This would be a breaking change, but I think this is a better breaking change than the one that was done in .NET 6. |
I understand that this order makes sense when thinking about child processes of But I do agree that the current behavior of |
I'm not sure about other operating systems, but for Windows the environment variables are propagated to child process by default. Starting a process on Windows with an empty environment is simple but not usable. Starting a process on Windows with the default environment variables set is quite complex.
I must be missing something here. I thought This issue affects all programs that are run with |
Vast majority of .NET programs are executed without By far the most common usage for Another one is apparently All the more reason that tools which do manipulate |
@agocke @vitek-karas Please make sure microsoft/vstest#3586 gets prioritized correctly. |
I agree with this -- the design intent is that DOTNET_ROOT is meant to be an override for the framework location. It seems complicated and confusing for, say, macOS ARM64 users to have to use This does, however, make things more complicated for users who want to start new processes. Most of the time, DOTNET_ROOT will not be set and there will be no action. But if DOTNET_ROOT is set, those users have to decide whether or not to pass the variable to their child process. There is no one correct answer here. People shipping their own private runtime and running system-installed tools, for instance, will likely not want to pass the variable to their children and will need to clear it during the Process.Start. People who want to use the same runtime for all their processes will want to pass it down. I agree with @vitek-karas that the best solution here is to limit DOTNET_ROOT setting in dotnet test. |
@rseanhall Reading through, it sounds like my characterization is incorrect:
It sounds like that's not true. If |
Vitek's proposed solution is for
|
Ah, I missed that, thanks. |
Sorry to have missed this (and that it took almost a year :-() The test infra implemented a change which did the ideal solution (not setting Looking at the current behavior the infra has two modes:
I tested the "with testhost" and the above description fits the observed behavior. I don't know if there's a way to force the "without testhost" case, which would be ideal for the use case here. @MarcoRossignoli or @Evangelink might know. |
Description
nethost returns location of 64-bit hostfxr.dll to 32-bit process.
Reproduction Steps
I have a custom native host that uses nethost to locate hostfxr.dll. I'm running into a problem when testing this native host inside of Xunit tests from "dotnet test". "dotnet test" is 64-bit and is setting DOTNET_ROOT to "C:\Program Files\dotnet". This environment variable is propagating all the way to the testhost.exe process. In my test, I'm calling
Process.Start
so that is also propagating to my 32-bit custom native host. This means that nethost is returning the path to a 64-bit hostfxr.dll for my 32-bit process.Expected behavior
Ignore DOTNET_ROOT since it is the wrong architecture.
Actual behavior
Trusts DOTNET_ROOT is correct.
Regression?
Yes. The issue seems to be from #53763. Before that change, x86 nethost would never have used DOTNET_ROOT, only DOTNET_ROOT(x86).
Known Workarounds
In my case, I can workaround this by clearing the DOTNET_ROOT environment variable. Presumably a 32-bit apphost would have the same problem, which might be harder to workaround.
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: