[release/10.0.4xx] Fix hostfxr resolution failure on musl - #55519
Merged
mthalman merged 1 commit intoJul 29, 2026
Merged
Conversation
When the host does not publish HOSTFXR_PATH, locate the highest semantic-versioned hostfxr under the running .NET installation root and load it explicitly. Adapt the unit coverage to the release branch's dotnet.Tests project because the Native AOT dn host is not present on this branch. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ed95a8e0-9252-4c0e-9e47-126be40a56bf
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
mthalman
marked this pull request as ready for review
July 29, 2026 13:42
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Backport of the musl hostfxr-resolution fix to release/10.0.4xx so SDK execution doesn’t fail when the host doesn’t provide the HOSTFXR_PATH runtime property (notably when launched via dotnet exec dotnet.dll).
Changes:
- Add a filesystem-based fallback (
HostFxrLocator+ sharedHostFxrPathResolver) that locates the highest semverhostfxrunder<dotnetRoot>/host/fxr/<version>/. - Update NativeWrapper’s unmanaged DLL resolver to use the fallback when
HOSTFXR_PATHis missing. - Add unit coverage in
dotnet.Testsand reference the NativeWrapper project for testing.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/NativeWrapperTests/HostFxrLocatorTests.cs | Adds unit tests for hostfxr path resolution, including prerelease ordering behaviors. |
| test/dotnet.Tests/dotnet.Tests.csproj | References Microsoft.DotNet.NativeWrapper so tests can access the internal locator logic. |
| src/Resolvers/Microsoft.DotNet.NativeWrapper/Microsoft.DotNet.NativeWrapper.csproj | Adds NuGet.Versioning, links in shared resolver source, and grants IVT to dotnet.Tests. |
| src/Resolvers/Microsoft.DotNet.NativeWrapper/Interop.cs | Uses the locator fallback when HOSTFXR_PATH is absent before loading hostfxr. |
| src/Resolvers/Microsoft.DotNet.NativeWrapper/HostFxrLocator.cs | Introduces NativeWrapper-facing entry point for resolving hostfxr path from dotnet root. |
| src/Common/HostFxrPathResolver.cs | Implements shared semver-based selection of hostfxr under host/fxr. |
baronfel
approved these changes
Jul 29, 2026
Member
Author
|
/tactics |
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.
Summary
Backports the hostfxr fallback fix (#55270) so SDK execution does not fail on musl when the host omits the
HOSTFXR_PATHruntime property. NativeWrapper now locates and loads the highest semantic-versioned hostfxr under the running .NET installation root.The release branch does not contain the Native AOT
dnhost from the original change, so this backport includes only the applicable NativeWrapper implementation and moves its coverage todotnet.Tests.Customer Impact
On musl-based distributions such as Alpine, commands that launch the SDK through
dotnet exec dotnet.dllcan abort withHostFxrRuntimePropertyNotSetExceptionwhenHOSTFXR_PATHis not set. This surfaced throughdnx --help, which exits with code 134, but can affect any path that reaches the NativeWrapper hostfxr resolver under the same conditions.Regression?
Yes, working in 10.0.3xx.
Testing
Microsoft.DotNet.NativeWrapperfornet10.0andnet472.net472Microsoft.DotNet.MSBuildSdkResolver, which source-globs NativeWrapper.HostFxrLocatorTestssuccessfully.Risk
Low. The new logic is only used when
HOSTFXR_PATHis absent. Existing resolution remains unchanged when the property is available. The fallback mirrors native host behavior by selecting the highest valid semantic-versioned hostfxr installation.