Support testhost.exe in TaskHost-launching tests#11956
Merged
rainersigwald merged 1 commit intodotnet:mainfrom Jun 6, 2025
Merged
Support testhost.exe in TaskHost-launching tests#11956rainersigwald merged 1 commit intodotnet:mainfrom
rainersigwald merged 1 commit intodotnet:mainfrom
Conversation
Some tests were failing when run from Visual Studio because they were running in a .NET 9 process launched as TestHost.exe, not in a dotnet.exe host. That caused TaskHost launching to try to run 'TestHost.exe MSBuild.dll' which failed, as TestHost isn't a general-purpose launcher. Add another fallback to GetCurrentHost to fall back to the current shared framework's parent dotnet.exe, if we can find it.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the host detection logic for .NET processes by adding a fallback that targets the parent dotnet.exe when running under TestHost.exe.
- Changed the return type of GetCurrentHost to allow null values.
- Added a new fallback branch to inspect EnvironmentUtilities.ProcessPath and, if necessary, derive the dotnet.exe path from the runtime directory.
Comments suppressed due to low confidence (1)
src/Build/BackEnd/Components/Communications/CurrentHost.cs:48
- The use of hard-coded folder levels (4) can reduce clarity; consider defining a named constant to indicate the intended directory depth for improved maintainability.
dotnetExe = Path.Combine(FileUtilities.GetFolderAbove(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), 4), dotnetExeName);
YuliiaKovalova
approved these changes
Jun 5, 2025
JanProvaznik
approved these changes
Jun 6, 2025
JanProvaznik
pushed a commit
to JanProvaznik/msbuild
that referenced
this pull request
Jun 12, 2025
Some tests were failing when run from Visual Studio because they were running in a .NET 9 process launched as `TestHost.exe`, not in a `dotnet.exe` host. That caused TaskHost launching to try to run `TestHost.exe MSBuild.dll` which failed, as TestHost isn't a general-purpose launcher. Add another fallback to `GetCurrentHost` to fall back to the current shared framework's parent `dotnet.exe`, if we can find it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some tests were failing when run from Visual Studio because they were running in a .NET 9 process launched as
TestHost.exe, not in adotnet.exehost. That caused TaskHost launching to try to runTestHost.exe MSBuild.dllwhich failed, as TestHost isn't a general-purpose launcher.Add another fallback to
GetCurrentHost()to fall back to the current shared framework's parentdotnet.exe, if we can find it.