Skip to content

Add dnx shim to dotnet-host package - #129258

Merged
mthalman merged 4 commits into
dotnet:mainfrom
mthalman:dev/mthalman/dotnet-host-dnx
Jun 12, 2026
Merged

mthalman merged 4 commits into
dotnet:mainfrom
mthalman:dev/mthalman/dotnet-host-dnx

Conversation

@mthalman

@mthalman mthalman commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

Per the .NET distribution-packaging guidelines, the dnx dispatcher script lives in the host package alongside the dotnet binary, with a /usr/bin/dnx symlink that resolves into /usr/share/dotnet/dnx. The script is SDK-version-independent.

Previously dnx was shipped from dotnet/sdk's Linux SDK package, which caused a dpkg file conflict on systems where Canonical's dotnet-host package was already installed (dotnet/sdk#53834).

This also updates the migrated dnx script with a fix for dotnet/sdk#54687.

This PR must ship alongside a corresponding dotnet/sdk change (dotnet/sdk#54688) that removes dnx from the dotnet-sdk package.

Contributes to dotnet/sdk#53834

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

This PR adds a dnx dispatcher script to the dotnet-host package output and introduces a Linux package symlink (/usr/bin/dnx → ../share/dotnet/dnx), so dnx is shipped alongside the dotnet host rather than from the SDK package.

Changes:

  • Publish a dnx shim into the host package output on Unix targets and mark it executable.
  • Add a Linux package symlink for dnx under /usr/bin.
  • Introduce the dnx dispatcher script that locates dotnet next to itself and dispatches into the latest installed SDK.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/installer/pkg/sfx/installers/dotnet-host.proj Publishes dnx and adds /usr/bin/dnx symlink; adds a chmod step.
src/installer/pkg/sfx/installers/dnx New dnx shell dispatcher script that resolves its install location and invokes the SDK entrypoint.

Comment thread src/installer/pkg/sfx/installers/dnx Resolved
mthalman and others added 2 commits June 10, 2026 15:07
The previous condition '$(TargetsUnix)' == 'true' is a target-OS gate and
runs unconditionally on the build machine. If a Unix-targeted host package is
ever built on a Windows host, chmod isn't on PATH and the build fails. Match
the existing pattern elsewhere in the file by additionally gating on host OS
via !$([MSBuild]::IsOSPlatform('windows')).

Co-authored-by: Copilot <[email protected]>
Three changes addressing review feedback on dotnet#129258:

1. Replace `readlink -f` with a POSIX `while [ -L ]` loop. The `-f` flag
   is a GNU extension and is not supported by macOS's BSD `readlink`
   before macOS 12.3 (and not at all in default POSIX). The loop walks
   any chain of symlinks (absolute or relative targets) and combines
   with `cd ... && pwd -P` to resolve the script's real install
   directory portably across Linux and macOS.

2. Detect the no-SDK case and emit a clear error instead of producing a
   confusing `.../sdk//dotnet.dll` path-not-found message when
   `dotnet --list-sdks` returns nothing.

3. `exec` the final `dotnet` invocation so the shell process is
   replaced rather than waiting on a child, giving correct signal
   handling and exit-code propagation without an extra process layer.

Co-authored-by: Copilot <[email protected]>
Replace the obsolescent `tail -1` shorthand with the POSIX-mandated
`tail -n 1` form. Every `tail` implementation we'd encounter (GNU,
BSD, macOS, busybox) supports both, but `-n N` is the form required by
POSIX and is preferred for portable `/bin/sh` scripts.
Copilot AI review requested due to automatic review settings June 11, 2026 15:24
@mthalman
mthalman enabled auto-merge (squash) June 11, 2026 15:26

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/installer/pkg/sfx/installers/dnx Resolved
@mthalman

Copy link
Copy Markdown
Member Author

/ba-g unrelated build job issue

@mthalman
mthalman merged commit 2f38215 into dotnet:main Jun 12, 2026
87 of 89 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
Per the [.NET distribution-packaging
guidelines](https://learn.microsoft.com/dotnet/core/distribution-packaging),
the dnx dispatcher script lives in the host package alongside the dotnet
binary, with a `/usr/bin/dnx` symlink that resolves into
`/usr/share/dotnet/dnx`. The script is SDK-version-independent.

Previously dnx was shipped from dotnet/sdk's Linux SDK package, which
caused a dpkg file conflict on systems where Canonical's `dotnet-host`
package was already installed (dotnet/sdk#53834).

This also updates the migrated `dnx` script with a fix for
dotnet/sdk#54687.

This PR must ship alongside a corresponding dotnet/sdk change
(dotnet/sdk#54688) that removes dnx from the
`dotnet-sdk` package.

---------

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants