Repository navigation
Move Windows dnx.cmd ownership from the SDK dev MSI to the sharedhost - #7719
Conversation
Windows follow-up to the dnx double-ship fix (dotnet/sdk#55241 for macOS). On Windows the SDK 'dev' MSI and the runtime sharedhost MSI both wrote dnx.cmd to the same install root, creating overlapping component packages (silent last-writer-wins / ref-count uninstall risk). Move dnx.cmd ownership to the sharedhost package and stop the SDK component from installing it. SDK (src/sdk): - GenerateInstallerLayout.targets: skip the dnx copy into the dev-MSI intermediate layout on Windows too (already skipped on macOS). LayoutDnxShim still emits dnx.cmd into the base redist layout (zip/tarball). - redist/dnx.cmd: end with 'endlocal & exit /b %ERRORLEVEL%' so the shim propagates dnx's exit code instead of swallowing it. Runtime (src/runtime): - New installers/dnx.cmd: Windows shim mirroring the Unix dnx shim, with a missing-SDK guard and exit-code propagation. - dotnet-host.proj: publish dnx.cmd to the sharedhost output on Windows. - host.wxs: add cmpDnxCmd component installing dnx.cmd to DOTNETHOME with a CopyFile to PROGRAMFILES_DOTNET, mirroring cmpCoreHost. Mirrors dotnet/sdk#55268 and dotnet/runtime#130686. Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd879cfe-e142-4eea-9d76-c5eb4467195f
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR moves Windows dnx.cmd installation/ownership from the SDK “dev” MSI to the runtime sharedhost MSI so only one installer writes dnx.cmd, aligning Windows behavior with the existing Unix host-provided dnx shim. It also updates the shim to preserve the executed command’s exit code.
Changes:
- Stop the SDK installer layout step from copying the
dnxshim into the MSI/PKG install root on Windows/macOS (leaving it to sharedhost). - Fix
dnx.cmdto propagate thednxinvocation’s exit code. - Add
dnx.cmdto the sharedhost installer payload and install it via WiX.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/sdk/src/Layout/redist/targets/GenerateInstallerLayout.targets | Stops SDK MSI/PKG intermediate layout from placing dnx at the install root on Windows/macOS to avoid overlapping ownership with sharedhost. |
| src/sdk/src/Layout/redist/dnx.cmd | Updates SDK’s dnx.cmd to propagate the exit code. |
| src/runtime/src/installer/pkg/sfx/installers/host.wxs | Adds a sharedhost MSI component to install dnx.cmd into DOTNETHOME (and copy to PROGRAMFILES_DOTNET). |
| src/runtime/src/installer/pkg/sfx/installers/dotnet-host.proj | Publishes dnx.cmd into the host installer staging output on non-Unix targets. |
| src/runtime/src/installer/pkg/sfx/installers/dnx.cmd | Introduces the sharedhost-owned Windows dnx.cmd shim. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Definitely need feedback from @joeloff on the impact of this and whether it will break anything. I can imagine due to the order things run in that this could leave you without a dnx.cmd, for example. I see a new dnx.cmd file being added, should there be a corresponding deletion of the old one? |
Align the SDK zip/tarball dnx.cmd with the runtime-owned dnx.cmd: clear SDK_VERSION before probing --list-sdks so a stale caller-environment value cannot be used, and error out with a clear message when no SDK is found instead of building a bogus SDK_PATH. The two copies are now identical. Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd879cfe-e142-4eea-9d76-c5eb4467195f
No, it's still bundled by the SDK for the zip file. |
Do we need to keep two copies in the source tree then? Can we use one copy as the source for both cases? |
I don't know how that would be done. Do you have suggestions? |
Oh, I guess the issue is that they're in different repos. Maybe the SDK build could extract it from a runtime package, but that's a lot more complicated. |
|
@mthalman that's how it works for Unix though? the dnx script is extracted from the host nupkg (I'm fine with the duplication if we want to get it in for p7 and clean up later) |
Resolve conflict in GenerateInstallerLayout.targets: main added the macOS-only dnx skip (from SDK PR #55241 codeflow); this branch extends it to Windows too. Kept the branch version (macOS + Windows skip). Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd879cfe-e142-4eea-9d76-c5eb4467195f
No, for Unix the sdk repo also has its own copy of the |
joeloff
left a comment
There was a problem hiding this comment.
Please fix the component authoring and verify the stable GUIDs from a build with the change against existing SDK installations.
Drop the hard-coded component GUID on the new dnx.cmd component and let WiX generate a stable GUID from the file keypath instead. A fixed GUID shared across per-architecture/version installers breaks MSI component reference counting for side-by-side installs and major upgrades. Omitting the Guid attribute matches the auto-generation pattern used by the other file/registry components in this file. Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd879cfe-e142-4eea-9d76-c5eb4467195f
Pin the sharedhost dnx.cmd component to the same stable GUID the SDK dev MSI used for [DOTNETHOME]\dnx.cmd so component identity is preserved as ownership of the file moves from the SDK MSI to the sharedhost. Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd879cfe-e142-4eea-9d76-c5eb4467195f
ok, sorry, looks like I confused this with something else. |
Hard-coding a single GUID makes the x86 sharedhost emit the x64 SDK's component GUID, mismatching the x86 SDK's path-derived GUID and breaking component ref-counting on x86. Omitting the Guid uses WiX's path-stable generation (the same algorithm heat used for the SDK harvest), which reproduces the correct per-architecture GUIDs automatically. Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd879cfe-e142-4eea-9d76-c5eb4467195f
Windows dnx.cmd ownership handoff — validation summaryAll scenarios validated using Preview 6 SDK as the "old" version and the bits from this PR as the "new" version. The host and SDK
New install (host owns dnx.cmd)
Existing-SDK coexistence handoff
Host upgrade
Result: PASS in all scenarios. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |


This is the Windows follow-up to dotnet/sdk#55116.
Today on Windows,
dnx.cmdis shipped only by the SDKdevMSI; the runtime sharedhost MSI does not ship it (the Unixdnxshim already lives in the host, but Windows was never brought into line). This change moves ownership ofdnx.cmdto the sharedhost package and stops the SDK component from installing it, so the two install roots stay in sync and only one MSI ever writesdnx.cmd.This also includes a fix in
dnx.cmdfor a preexisting issue to ensure thatdnx's exit code is propagated instead of resetting it to 0.