Skip to content

Fix forwarding DOTNET_ROOT #49634

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

Merged
merged 6 commits into from
Jul 29, 2025
Merged

Fix forwarding DOTNET_ROOT #49634

merged 6 commits into from
Jul 29, 2025

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented Jul 2, 2025

Use VSTEST_DOTNET_ROOT_PATH and VSTEST_DOTNET_ROOT_ARCHITECTURE to tell to child vstest.console where the dotnet sdk is, so we can use it to setup dotnet_root for testhost.exe correctly, so testhost can pick up privately instaled dotnet sdk.

Needs microsoft/vstest#15184 to be merged first.

Fix #49436


// We rename env variable to support --arch switch that relies on DOTNET_ROOT/DOTNET_ROOT(x86)
// We provide VSTEST_WINAPPHOST_ only in case of testhost*.exe removing VSTEST_WINAPPHOST_ prefix and passing as env vars.
return (hasRootVariable, $"VSTEST_WINAPPHOST_{rootVariableName}", rootValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm double checking, this is fine because this logic isn't going to be used with old vstest.console.exe because it's guaranteed that we use vstest.console.exe that's part of SDK, and we will only merge this PR after inserting the fix on vstest side. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the old way of doing this can be removed. It also does not seem that people use that env variable on its own.

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels much better than what I originally had in mind. Hopefully it's going to work the way we expect it to :)

If we needed to service this in .NET 9 or 8, I assume we will need to also service the respective vstest versions inserted in 8 and 9?

@nohwnd
Copy link
Member Author

nohwnd commented Jul 17, 2025

Update merged, let's test it together. #49809

@nohwnd
Copy link
Member Author

nohwnd commented Aug 12, 2025

/backport to release/9.0.3xx

Copy link
Contributor

Started backporting to release/9.0.3xx: https://github.com/dotnet/sdk/actions/runs/16902587194

Copy link
Contributor

@nohwnd backporting to "release/9.0.3xx" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix forwarding dotnet_root
Using index info to reconstruct a base tree...
A	src/Cli/dotnet/Commands/Test/TestCommand.cs
A	src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs
A	src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs
M	src/Cli/dotnet/Parser.cs
A	test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetVsTestForwardingApp.cs
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): src/Cli/dotnet/Commands/Test/TestCommand.cs deleted in HEAD and modified in Fix forwarding dotnet_root.  Version Fix forwarding dotnet_root of src/Cli/dotnet/Commands/Test/TestCommand.cs left in tree.
CONFLICT (modify/delete): src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs deleted in HEAD and modified in Fix forwarding dotnet_root.  Version Fix forwarding dotnet_root of src/Cli/dotnet/Commands/Test/VSTestForwardingApp.cs left in tree.
CONFLICT (modify/delete): src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs deleted in HEAD and modified in Fix forwarding dotnet_root.  Version Fix forwarding dotnet_root of src/Cli/dotnet/Commands/VSTest/VSTestCommand.cs left in tree.
Auto-merging src/Cli/dotnet/Parser.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Parser.cs
Auto-merging test/dotnet.Tests/dotnet-msbuild/GivenDotnetVsTestForwardingApp.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Fix forwarding dotnet_root
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

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

Successfully merging this pull request may close these issues.

[NetTestingE2E][Regression] Error "The library hostfxr.dll was found..." will throw when executing "dotnet test --arch x86 --diag:log1.txt".
2 participants