Skip to content

[release/10.0.4xx] Fix hostfxr resolution failure on musl - #55519

Merged
mthalman merged 1 commit into
dotnet:release/10.0.4xxfrom
mthalman:mthalman-backport-hostfxr-musl-fix
Jul 29, 2026
Merged

[release/10.0.4xx] Fix hostfxr resolution failure on musl#55519
mthalman merged 1 commit into
dotnet:release/10.0.4xxfrom
mthalman:mthalman-backport-hostfxr-musl-fix

Conversation

@mthalman

@mthalman mthalman commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

Backports the hostfxr fallback fix (#55270) so SDK execution does not fail on musl when the host omits the HOSTFXR_PATH runtime 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 dn host from the original change, so this backport includes only the applicable NativeWrapper implementation and moves its coverage to dotnet.Tests.

Customer Impact

On musl-based distributions such as Alpine, commands that launch the SDK through dotnet exec dotnet.dll can abort with HostFxrRuntimePropertyNotSetException when HOSTFXR_PATH is not set. This surfaced through dnx --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

  • Added 11 unit tests covering hostfxr path resolution, platform-specific library names, missing paths, prerelease versions, and semantic-version ordering.
  • Built Microsoft.DotNet.NativeWrapper for net10.0 and net472.
  • Built the net472 Microsoft.DotNet.MSBuildSdkResolver, which source-globs NativeWrapper.
  • Ran all 11 HostFxrLocatorTests successfully.

Risk

Low. The new logic is only used when HOSTFXR_PATH is 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.

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

Copy link
Copy Markdown
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
mthalman marked this pull request as ready for review July 29, 2026 13:42
Copilot AI review requested due to automatic review settings July 29, 2026 13:42
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 + shared HostFxrPathResolver) that locates the highest semver hostfxr under <dotnetRoot>/host/fxr/<version>/.
  • Update NativeWrapper’s unmanaged DLL resolver to use the fallback when HOSTFXR_PATH is missing.
  • Add unit coverage in dotnet.Tests and 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.

Comment thread src/Common/HostFxrPathResolver.cs
@mthalman
mthalman merged commit 32593ca into dotnet:release/10.0.4xx Jul 29, 2026
30 checks passed
@mthalman
mthalman deleted the mthalman-backport-hostfxr-musl-fix branch July 29, 2026 14:51
@mthalman

Copy link
Copy Markdown
Member Author

/tactics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants