Skip to content

Use a version-specific CLI bundle for pinned DNX AppHost invocations - #21473

Merged
Ankit Jain (radical) merged 7 commits into
mainfrom
aspireagent/fix-21463-pinned-dnx-bundle
Nov 10, 2026
Merged

Ankit Jain (radical) merged 7 commits into
mainfrom
aspireagent/fix-21463-pinned-dnx-bundle

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Addresses the DnxPinned half of #21463: an AppHost whose CLI invocation is pinned to its own Aspire.Hosting.AppHost version could still orchestrate with a DCP from a different (older) global CLI.

Root cause

With AspireCliInvocationMode=DnxPinned, ResolveAspireCliBundlePaths passes no CLI path to ResolveAspireCliBundle. 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 pinned setup --install-path ever runs. If setup did run, it extracted into that same shared home, and BundleService prunes other versions/* entries there, which could disturb the global CLI's layout.

Fix

  • ResolveAspireCliBundle gets a PinnedAspireCliVersion input. When set (and no explicit AspireCliBundlePath/AspireCliPath), it resolves only from $ASPIRE_HOME/dnx/aspire.cli/<version> and reports that directory through a new AspireCliSetupDirectory output. The version is sanitized so it cannot escape that directory.
  • When AspireCliInvocationMode=DnxPinned resolves to DNX, the AppHost targets derive the pinned version from _AspireCliDnxPackageReference (the exact package DNX will run) and point the DNX setup --install-path at the version-specific directory.
  • The CLI validates an extracted bundle through layout discovery, which does not probe custom install paths. RunAspireCliCommand gains an EnvironmentVariables input, and the pinned setup runs with ASPIRE_LAYOUT_PATH set to the pinned directory so validation succeeds on clean machines. The fake dnx/CLI used by the tests now enforce the same rule: setup fails unless the install path is ASPIRE_LAYOUT_PATH or the Aspire home.
  • Unchanged: explicit Dnx mode (unversioned, manifest-aware package) and all default Path-mode behavior, including reusing the Aspire home bundle when no CLI is on PATH (covered by MSBuildTests.CliBundleOptInResolvesAspireHomeBundleWithoutCliOnPath), plus explicit AspireCliBundlePath/AspireCliPath.
  • Not in this PR: AppHost silently uses a DCP bundle that doesn't match its SDK version (Path default; DnxPinned accepts shared-home layout) #21463 also covers the default Path mode, 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: with DnxPinned, a complete stale bundle exists in ASPIRE_HOME; DcpDir must 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.
  • No existing tests or assertions are changed.
Result
Before (main bf29669, src reverted) New pinned tests fail: Expected: …/aspire-home/dnx/aspire.cli/13.5.0/bundle/dcp / Actual: …/aspire-home/bundle/dcp
Before the ASPIRE_LAYOUT_PATH fix (review finding) ResolveAspireCliBundlePathsUsesPinnedDnxBundleInsteadOfSharedAspireHomeBundle fails: ASPIRE009 … Bundle was extracted to …/aspire-home/dnx/aspire.cli/13.5.0 but layout validation failed
After Aspire.Hosting.Sdk.Tests (excluding quarantined/outerloop): 92 passed, 3 skipped (platform-gated), 0 failed

Checklist

🤖 Posted by AspireAgent (AI Agent)

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>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21473

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21473"

@github-actions

This comment has been minimized.

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.

🟡 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>

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.

🟢 Approval recommended

No active review issues block the change to isolate CLI bundles by pinned version.

1 open issue

Review effort: Balanced

@github-actions

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>

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.

🟢 Approval recommended

No active review issues remain for the pinned CLI bundle isolation change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copy link
Copy Markdown
Collaborator Author

CI on exact head 6d37e34f is green: 286 checks passed, 16 skipped, 0 failed.

Known flaky failure, rerun once: on attempt 1, Hosting.DevTunnels (ubuntu-latest) failed in DevTunnelMonitorTests.OlderReconciliationCannotUndoNewerLogObservations and UnrecognizedOutputWarnsOnceAndReconcilesReadiness with ObjectDisposedException (disposed IServiceProvider). This is the known flake tracked in #21172; DevTunnels isn't touched by this PR. The automatic failed-job rerun passed on attempt 2 of run 41091122460.

The Copilot review finding (ASPIRE_LAYOUT_PATH for the pinned setup) is addressed and resolved; the latest review on this head reports no open issues.

🤖 Posted by AspireAgent (AI Agent)

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 30, 2026 17:28
@davidfowl David Fowler (davidfowl) added the agent:working An AI agent is actively working on this issue or PR label Nov 6, 2026 — with Copilot SWE Agent
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator Author

Merged main into this branch to resolve a conflict in docs/list-of-diagnostics.md. main rewrote the CLI-bundle paragraph to mention ASPIRE013 and the non-C# ASPIRE010 warning. I kept main's wording and added this PR's sentence about DnxPinned preparing the bundle in $ASPIRE_HOME/dnx/aspire.cli/<version>. Code files merged without conflicts.

Local tests: AppHostSdkTargetsTests passed 93, failed 0 and skipped 4 (Windows-only or conditional). The run included this PR's new pinned-DNX tests.

🤖 Posted by AspireAgent (AI Agent)

@davidfowl David Fowler (davidfowl) removed the agent:working An AI agent is actively working on this issue or PR label Nov 6, 2026
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 6, 2026 07:31
@github-actions

This comment has been minimized.

@davidfowl David Fowler (davidfowl) added the agent:working An AI agent is actively working on this issue or PR label Nov 7, 2026 — with Copilot SWE Agent

Copy link
Copy Markdown
Collaborator Author

Merged main into this branch to resolve the conflict introduced by #21545.

Conflict: docs/list-of-diagnostics.md — both sides rewrote the invocation-mode paragraph. Kept main's new ASPIRE014 sentence (unsupported AspireCliInvocationMode values fall back to Path) and appended this PR's sentence about DnxPinned resolving the bundle from $ASPIRE_HOME/dnx/aspire.cli/<version>. Aspire.Hosting.AppHost.in.targets auto-merged; the dnxpinned checks are consistent with #21545's mode validation.

Local tests: Aspire.Hosting.Sdk.Tests → AppHostSdkTargetsTests: 105 total, 101 passed, 0 failed, 4 skipped (Windows/full-framework only).

🤖 Posted by AspireAgent (AI Agent)

@davidfowl David Fowler (davidfowl) removed the agent:working An AI agent is actively working on this issue or PR label Nov 7, 2026
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 7, 2026 00:55
@github-actions

This comment has been minimized.

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.

🟢 Approval recommended

No active review issues remain for the pinned-version bundle isolation change.

No open issues 🎉

Review effort: Balanced

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>
@github-actions

This comment has been minimized.

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.

🟢 Approval recommended

No active review issues are reported for the pinned CLI bundle isolation change.

No open issues 🎉

Review effort: Balanced

@radical Ankit Jain (radical) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved. One non-blocking test-coverage suggestion is included inline; it can be addressed in a follow-up PR.

@radical
Ankit Jain (radical) enabled auto-merge (squash) November 10, 2026 17:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

45 / 101 PR test projects · 3 PR jobs, from 5 changed files.

Selected PR test projects (45 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Sdk.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests

Selected PR jobs (3)

cli-starter-validation, extension-e2e, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 43 of the 45 selected test projects come from a single change — src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets.

🔧 src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets (changed source)
→ 43 via the project graph

show 43

Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests

📦 affected project Aspire.Hosting.AppHost
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Sdk.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.AppHost
extension-e2e • src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets
• affected project Aspire.Hosting.AppHost
typescript-api-compat affected project Aspire.Hosting.AppHost

Selection computed for commit fbcb30a.

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.

🟢 Approval recommended

No active review issues are reported for the pinned-version CLI bundle isolation change.

No open issues 🎉

Review effort: Balanced

@radical
Ankit Jain (radical) merged commit 32d2dd9 into main Nov 10, 2026
312 checks passed
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2104

Generated by PR Documentation Check · copilot · auto · 27 AIC · ⌖ 1.17 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2104 targeting release/17.0.

Documented that DnxPinned mode resolves the CLI bundle from a version-specific $ASPIRE_HOME/dnx/aspire.cli/<version> directory in get-started/aspire-sdk.mdx. Triggered signals: pr_body_has_cli_flag_mention (PR body: pinned setup --install-path), diagnostic_documentation_changed (docs/list-of-diagnostics.md).

Note

This draft PR needs human review before merging.

David Fowler (davidfowl) added a commit that referenced this pull request Nov 10, 2026
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>
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants