Repository navigation
Use a version-specific CLI bundle for pinned DNX AppHost invocations - #21473
Conversation
DnxPinned (and Path mode falling back to the pinned DNX CLI) resolved the CLI bundle from the shared Aspire home before running setup, so a layout from an older global CLI supplied a DCP that did not match the AppHost package version. Setup also extracted into the shared home, pruning the global CLI's versioned layout. Pinned DNX invocations now resolve and set up the bundle only in $ASPIRE_HOME/dnx/aspire.cli/<version>. Fixes part of #21463. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21473Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21473" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
On clean DNX-only installations, setup cannot discover the nested destination, causing extraction failure and rollback that MSBuild can mask by resolving leftover payloads.
1 open issue
What changed in this PR
This PR isolates bundles used by version-pinned DNX AppHosts from the shared global CLI bundle, addressing the pinned-invocation portion of #21463. The global PATH CLI mismatch warning remains out of scope.
Changes:
- Resolve pinned bundles under
$ASPIRE_HOME/dnx/aspire.cli/<version>with sanitized version directory names. - Direct pinned DNX setup to that version-specific location.
- Add regression tests and document the new resolution behavior.
| File | Description |
|---|---|
tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs |
Tests pinned bundle isolation, reuse, sanitization, and setup paths. |
src/Aspire.Hosting.Tasks/ResolveAspireCliBundle.cs |
Adds pinned-version resolution and a setup-directory output. |
src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets |
Derives the pinned version and wires resolution and setup paths. |
docs/list-of-diagnostics.md |
Documents version-specific DNX bundle locations. |
Review effort: Balanced
Default Path mode intentionally reuses the Aspire home bundle when no CLI is on PATH (MSBuildTests.CliBundleOptInResolvesAspireHomeBundleWithoutCliOnPath), so keep that behavior and only isolate explicit DnxPinned layouts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The CLI validates an extracted bundle through layout discovery, which only probes ASPIRE_LAYOUT_PATH, the CLI's own location and the Aspire home. A DNX-hosted CLI extracting into the version-specific pinned directory therefore failed validation on clean machines. Pass ASPIRE_LAYOUT_PATH to that setup command, and make the fake dnx/CLI enforce the same rule. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
CI on exact head Known flaky failure, rerun once: on attempt 1, The Copilot review finding ( 🤖 Posted by AspireAgent (AI Agent) |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Merged Local tests: 🤖 Posted by AspireAgent (AI Agent) |
This comment has been minimized.
This comment has been minimized.
|
Merged Conflict: Local tests: 🤖 Posted by AspireAgent (AI Agent) |
This comment has been minimized.
This comment has been minimized.
The pinned DnxPinned setup only validates its extracted layout when ASPIRE_LAYOUT_PATH points at the version-specific install directory, so include that requirement in the ASPIRE009 rerun guidance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Ankit Jain (radical)
left a comment
There was a problem hiding this comment.
Approved. One non-blocking test-coverage suggestion is included inline; it can be addressed in a follow-up PR.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests selector45 / 101 PR test projects · 3 PR jobs, from 5 changed files. Selected PR test projects (45 / 101)
Selected PR jobs (3)
How these were chosen — grouped by what changed
🔧 show 43
📦 affected project 🧪 Job reasons
Selection computed for commit |
|
Pull request created: #2104
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#2104 targeting Documented that Note This draft PR needs human review before merging. |
Resolve docs/list-of-diagnostics.md conflict with #21473 by keeping the DnxPinned bundle-location sentence and the ASPIRE015 precedence sentence. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Description
Addresses the
DnxPinnedhalf of #21463: an AppHost whose CLI invocation is pinned to its ownAspire.Hosting.AppHostversion could still orchestrate with a DCP from a different (older) global CLI.Root cause
With
AspireCliInvocationMode=DnxPinned,ResolveAspireCliBundlePathspasses no CLI path toResolveAspireCliBundle. The task then falls back to the shared Aspire home (~/.aspire) and accepts any complete layout there, so a bundle left by an older global CLI wins before the pinnedsetup --install-pathever runs. If setup did run, it extracted into that same shared home, andBundleServiceprunes otherversions/*entries there, which could disturb the global CLI's layout.Fix
ResolveAspireCliBundlegets aPinnedAspireCliVersioninput. When set (and no explicitAspireCliBundlePath/AspireCliPath), it resolves only from$ASPIRE_HOME/dnx/aspire.cli/<version>and reports that directory through a newAspireCliSetupDirectoryoutput. The version is sanitized so it cannot escape that directory.AspireCliInvocationMode=DnxPinnedresolves to DNX, the AppHost targets derive the pinned version from_AspireCliDnxPackageReference(the exact package DNX will run) and point the DNXsetup --install-pathat the version-specific directory.RunAspireCliCommandgains anEnvironmentVariablesinput, and the pinned setup runs withASPIRE_LAYOUT_PATHset to the pinned directory so validation succeeds on clean machines. The fakednx/CLI used by the tests now enforce the same rule: setup fails unless the install path isASPIRE_LAYOUT_PATHor the Aspire home.Dnxmode (unversioned, manifest-aware package) and all defaultPath-mode behavior, including reusing the Aspire home bundle when no CLI is onPATH(covered byMSBuildTests.CliBundleOptInResolvesAspireHomeBundleWithoutCliOnPath), plus explicitAspireCliBundlePath/AspireCliPath.Pathmode, where a global CLI's (or shared home) bundle may not match the hosting packages. Changing that default, or adding a mismatch warning, needs a separate design decision, so the issue should stay open for it.Reproduction / before-after evidence
New tests in
AppHostSdkTargetsTests:ResolveAspireCliBundlePathsUsesPinnedDnxBundleInsteadOfSharedAspireHomeBundle: withDnxPinned, a complete stale bundle exists inASPIRE_HOME;DcpDirmust come from the pinned layout, and the shared bundle must be left intact.ResolveAspireCliBundlePathsReusesExistingPinnedDnxBundle: an existing pinned layout is used without running setup (the fake DNX fails setup).ResolveAspireCliBundlePinnedLayoutDirectoryStaysUnderAspireHome: version sanitization.Expected: …/aspire-home/dnx/aspire.cli/13.5.0/bundle/dcp/Actual: …/aspire-home/bundle/dcpASPIRE_LAYOUT_PATHfix (review finding)ResolveAspireCliBundlePathsUsesPinnedDnxBundleInsteadOfSharedAspireHomeBundlefails:ASPIRE009 … Bundle was extracted to …/aspire-home/dnx/aspire.cli/13.5.0 but layout validation failedAspire.Hosting.Sdk.Tests(excluding quarantined/outerloop): 92 passed, 3 skipped (platform-gated), 0 failedChecklist
Path-mode mismatch from AppHost silently uses a DCP bundle that doesn't match its SDK version (Path default; DnxPinned accepts shared-home layout) #21463)Aspire.Hosting.Tasks, which has no tracked API surface)🤖 Posted by AspireAgent (AI Agent)