Skip to content

Warn when AspireCliPath overrides a DNX AspireCliInvocationMode - #21592

Merged
Ankit Jain (radical) merged 9 commits into
mainfrom
aspireagent/warn-cli-path-overrides-dnx-19713
Nov 11, 2026
Merged

Ankit Jain (radical) merged 9 commits into
mainfrom
aspireagent/warn-cli-path-overrides-dnx-19713

Conversation

@davidfowl

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

Copy link
Copy Markdown
Collaborator

Description

An explicit AspireCliPath takes precedence over AspireCliInvocationMode. That precedence is intentional and covered by ComputeRunArgumentsUsesConfiguredAspireCliPathWhenDnxModeIsConfigured. But AspireCliPath is often inherited from the environment; for example, the Aspire VS Code extension sets it for its terminals. In that case, a project that explicitly sets AspireCliInvocationMode=Dnx/DnxPinned silently runs the installed CLI instead, with nothing in the build output to say why.

This takes option 2 from the issue. _ResolveAspireCliInvocation now emits a suppressible ASPIRE015 warning when AspireCliPath overrides an explicit Dnx/DnxPinned mode. The warning names the path and tells the user how to opt into DNX (an empty <AspireCliPath></AspireCliPath> in the AppHost project) or how to silence it. Precedence is unchanged. docs/list-of-diagnostics.md documents the new diagnostic.

Fixes #19713

Diagnostic ID: renumbered from ASPIRE013 to ASPIRE015. #21288 (merged) uses ASPIRE013 for the required C# CLI-bundle error, and #21545 proposes ASPIRE014. The branch now merges main to pick up #21288. The output samples below show the warning under its new ID.

Root cause

ResolveAspireCliInvocation.Execute returns Aspire mode as soon as AspireCliPath is non-empty, before it looks at AspireCliInvocationMode. The targets only logged the selection at Importance="Low", which is visible only in diagnostic verbosity (as the issue's /v:diag repro shows).

Before / after

Unit tests (Aspire.Hosting.Sdk.Tests, real dotnet msbuild -t:ComputeRunArguments against a generated AppHost with AspireCliPath in the environment):

  • ComputeRunArgumentsWarnsWhenAmbientAspireCliPathOverridesDnxMode (Dnx, DnxPinned, dNxPiNnEd): 3/3 fail before (no ASPIRE015 in output), pass after. They also assert that the resolved mode is still Aspire and that RunCommand is still the configured path.
  • ComputeRunArgumentsDoesNotWarnWhenAspireCliPathDoesNotOverrideDnxMode (Path mode; DnxPinned with NoWarn=ASPIRE015): passes before and after.
  • Full Aspire.Hosting.Sdk.Tests locally after the renumber and merge with main: 103 passed, 0 failed (3 Windows-only skipped).
  • After review feedback (suppression now relies on MSBuild's built-in NoWarn handling instead of an explicit check in the warning condition; _AspireUseDnxCliRunHook renamed to _AspireCliInvocationModeRequestsDnx): the NoWarn=ASPIRE015 case still passes, and the full Aspire.Hosting.Sdk.Tests run passes locally (119 passed, 0 failed, 4 platform-specific skips).

E2E with a real AppHost and the Aspire CLI (Linux, playground/CustomResources/CustomResources.AppHost temporarily set to <AspireCliInvocationMode>DnxPinned</AspireCliInvocationMode>, with AspireCliPath=<aspire.cli 13.6.4> in the environment, as the VS Code extension sets it, then dotnet run):

Before (main): the CLI from AspireCliPath runs the AppHost, with no diagnostic:

Using launch settings from .../CustomResources.AppHost/Properties/launchSettings.json...
...
   Dashboard:  https://CustomResources.dev.localhost:16159/login?t=...

After: same launch (precedence unchanged), and the override is now visible:

Using launch settings from .../CustomResources.AppHost/Properties/launchSettings.json...
.../Aspire.Hosting.AppHost.in.targets(241,5): warning ASPIRE015: CustomResources.AppHost: AspireCliInvocationMode=DnxPinned is ignored because AspireCliPath is set to '/tmp/aspirecli/aspire'. AspireCliPath takes precedence over AspireCliInvocationMode and may be inherited from the environment, for example from the Aspire VS Code extension. To use DNX, clear it in the AppHost project with an empty <AspireCliPath></AspireCliPath> property. To keep using AspireCliPath, remove AspireCliInvocationMode or add ASPIRE015 to NoWarn.
...
   Dashboard:  https://CustomResources.dev.localhost:16159/login?t=...

Following the warning's advice (adding <AspireCliPath></AspireCliPath> to the playground project, with the environment variable still set) resolves _AspireResolvedCliInvocationMode=Dnx and emits no ASPIRE015. The playground change was local proof only and is not committed: pinning the in-repo playground to DnxPinned would make it request an unpublished aspire.cli dev version.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

An explicit AspireCliPath takes precedence over AspireCliInvocationMode, but it is
often inherited from the environment (the Aspire VS Code extension sets it for its
terminals). That silently replaced an explicitly requested Dnx/DnxPinned mode.
Emit a suppressible ASPIRE013 warning in _ResolveAspireCliInvocation so the
override is visible, without changing precedence.

Fixes #19713

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

Or

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

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 31, 2026
@github-actions

This comment has been minimized.

On Windows the fake CLI is a .cmd shim, so RunCommand is cmd.

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.

🟡 Changes recommended

The new assertion compares RunCommand directly with the CLI shim path, causing all three theory cases to fail on Windows where the expected command is cmd; it should use GetExpectedAspireRunCommand.

1 open issue
What changed in this PR

Adds a visible warning when AspireCliPath overrides an explicitly configured DNX invocation mode, addressing #19713 without changing CLI selection precedence.

Changes:

  • Emits suppressible ASPIRE013 with guidance for clearing the path override.
  • Adds regression tests for warnings, suppression, case-insensitive modes, and preserved precedence.
  • Documents the diagnostic and CLI selection behavior.
File Description
tests/​Aspire.Hosting.Sdk.Tests/​AppHostSdkTargetsTests.cs Adds warning and suppression regression tests.
src/​Aspire.Hosting.AppHost/​build/​Aspire.Hosting.AppHost.in.targets Emits ASPIRE013 when a path overrides DNX mode.
docs/​list-of-diagnostics.md Documents ASPIRE013 and path precedence.

Review effort: Balanced

@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 change that warns when AspireCliPath overrides an explicit DNX mode.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@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 note: on run attempt 1 for d62cf87, three Windows jobs (Hosting-6, Hosting.DevTunnels, VS Code extension E2E settings-files) failed with "The hosted runner lost communication with the server". That's an infrastructure issue unrelated to this MSBuild targets change. Run 41206981272 retried the failed jobs automatically (attempt 2), and all three passed. All checks are now green at d62cf87.

🤖 Posted by AspireAgent (AI Agent)

@IEvangelist

Copy link
Copy Markdown
Member

Diagnostic-ID coordination: #21288 is keeping ASPIRE013 for the required C# CLI-bundle error, restoring ASPIRE010 to its original suppressible warning. Please renumber this PR's AspireCliPath/DNX warning before it merges, updating the help link, diagnostic list, suppression guidance, and tests together. #19880 also currently proposes ASPIRE013, and #21545 uses ASPIRE014, so please coordinate distinct unused IDs rather than reusing either one.

@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
#21288 keeps ASPIRE013 for the required C# CLI-bundle error and #21545
proposes ASPIRE014, so move this warning to the next unused ID.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…path-overrides-dnx-19713

# Conflicts:
#	docs/list-of-diagnostics.md
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 6, 2026 05:27

Copy link
Copy Markdown
Collaborator Author

David Pine (@IEvangelist) Thanks for the heads-up. I renumbered this PR's AspireCliPath/DNX override warning to ASPIRE015 in 0dc22a5.

Diagnostic-ID coordination: #21288 is keeping ASPIRE013 …

Why 015: main (with #21288 merged) uses ASPIRE001–ASPIRE013 in code and in docs/list-of-diagnostics.md. #21545 proposes ASPIRE014, and #19880 proposes ASPIRE013. I checked the diffs of all open PRs, and none adds ASPIRE015.

What changed (6a4cc56): the <Warning Code>, the NoWarn suppression regex and the suppression guidance in the targets file. Also the diagnostics-list row, the precedence note, the tests (warning ASPIRE015 assertion, NoWarn=ASPIRE015 case, DoesNotContain) and the PR body. This warning never had an aka.ms help link, so there was no link to update. Every remaining ASPIRE013 reference is #21288's CLI-bundle error.

Merge with main (0dc22a5): #21288 merged after your comment, and the PR started to conflict in docs/list-of-diagnostics.md. I merged main with a merge commit (no rebase or force-push) and resolved the conflict by keeping main's ASPIRE013 error row and adding this PR's row as ASPIRE015.

Tests: I ran the full Aspire.Hosting.Sdk.Tests locally on Linux at 0dc22a5: 103 passed, 0 failed, 3 skipped (Windows-only).

🤖 Posted by AspireAgent (AI Agent)

@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.

Reviewed the latest change removing the redundant NoWarn check and renaming the DNX-mode property. The coded ASPIRE015 warning is correctly delegated to MSBuild's NoWarn handling, and the change preserves the intended warning condition and existing CLI precedence. No issues found. CI is still in progress.

@radical
Ankit Jain (radical) enabled auto-merge (squash) November 10, 2026 23:18

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 were identified for the changes clarifying when AspireCliPath overrides a requested DNX invocation mode.

No open issues 🎉

Review effort: Balanced

@radical Ankit Jain (radical) removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 10, 2026
@github-actions

This comment has been minimized.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 10, 2026 23:47
@davidfowl David Fowler (davidfowl) removed the agent:working An AI agent is actively working on this issue or PR label Nov 10, 2026

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 were identified for this change.

No open issues 🎉

Review effort: Balanced

@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 10, 2026 — with Copilot SWE Agent

Copy link
Copy Markdown
Collaborator Author

Merged main into this branch only to pick up #21874's Go starter resource rename (api → app). The CLI starter validation needs that rename: the CLI under test is built from the merge ref, while the validation script ran from the stale branch. There are no logic changes. Ankit Jain (@radical)'s "Route AppHost targets changes to SDK tests" commit is kept, and the ASPIRE015 tests (including the NoWarn suppression case) still pass locally.

🤖 Posted by AspireAgent (AI Agent)

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

45 / 101 PR test projects · 3 PR jobs, from 3 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

⚠️ 44 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)
→ 44 via the project graph

show 44

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

📦 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

🧪 tests/Aspire.Hosting.Sdk.Tests/Aspire.Hosting.Sdk.Tests.csproj (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 c3eae23.

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 change introducing the suppressible ASPIRE015 warning.

No open issues 🎉

Review effort: Balanced

@davidfowl David Fowler (davidfowl) removed the agent:working An AI agent is actively working on this issue or PR label Nov 11, 2026
@radical
Ankit Jain (radical) merged commit a256719 into main Nov 11, 2026
312 of 313 checks passed
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2110

Generated by PR Documentation Check · copilot · auto · 25 AIC · ⌖ 1.19 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

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

Added a new ASPIRE015 diagnostic page, an overview table row, and a sidebar entry. Triggered signal: diagnostic_documentation_changed (evidence: docs/list-of-diagnostics.md adds ASPIRE015).

Note

This draft PR needs human review before merging.

@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 11, 2026
Maddy Montaquila (maddymontaquila) added a commit to microsoft/aspire.dev that referenced this pull request Nov 17, 2026
ASPIRE015 is a warning, so list it under Warnings next to ASPIRE012.
Add the 'Version introduced: 17.1' badge (microsoft/aspire#21592 ships
in 17.1) and quote the full warning text from the AppHost targets.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

AspireCliInvocationMode=DnxPinned is overridden by ambient AspireCliPath environment variable in VS Code

4 participants