Repository navigation
Warn when AspireCliPath overrides a DNX AspireCliInvocationMode - #21592
Conversation
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>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21592Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21592" |
This comment has been minimized.
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>
There was a problem hiding this comment.
🟡 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
ASPIRE013with 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
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 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) |
|
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. |
…path-overrides-dnx-19713 # Conflicts: # docs/list-of-diagnostics.md
|
David Pine (@IEvangelist) Thanks for the heads-up. I renumbered this PR's AspireCliPath/DNX override warning to
Why 015: What changed (6a4cc56): the Merge with main (0dc22a5): #21288 merged after your comment, and the PR started to conflict in Tests: I ran the full 🤖 Posted by AspireAgent (AI Agent) |
Ankit Jain (radical)
left a comment
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
…path-overrides-dnx-19713
|
Merged 🤖 Posted by AspireAgent (AI Agent) |
Tests selector45 / 101 PR test projects · 3 PR jobs, from 3 changed files. Selected PR test projects (45 / 101)
Selected PR jobs (3)
How these were chosen — grouped by what changed
🔧 show 44
📦 affected project 🧪 🧪 Job reasons
Selection computed for commit |
|
Pull request created: #2110
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#2110 targeting Added a new ASPIRE015 diagnostic page, an overview table row, and a sidebar entry. Triggered signal: Note This draft PR needs human review before merging. |
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>

Description
An explicit
AspireCliPathtakes precedence overAspireCliInvocationMode. That precedence is intentional and covered byComputeRunArgumentsUsesConfiguredAspireCliPathWhenDnxModeIsConfigured. ButAspireCliPathis often inherited from the environment; for example, the Aspire VS Code extension sets it for its terminals. In that case, a project that explicitly setsAspireCliInvocationMode=Dnx/DnxPinnedsilently runs the installed CLI instead, with nothing in the build output to say why.This takes option 2 from the issue.
_ResolveAspireCliInvocationnow emits a suppressibleASPIRE015warning whenAspireCliPathoverrides an explicitDnx/DnxPinnedmode. 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.mddocuments the new diagnostic.Fixes #19713
Root cause
ResolveAspireCliInvocation.ExecutereturnsAspiremode as soon asAspireCliPathis non-empty, before it looks atAspireCliInvocationMode. The targets only logged the selection atImportance="Low", which is visible only in diagnostic verbosity (as the issue's/v:diagrepro shows).Before / after
Unit tests (
Aspire.Hosting.Sdk.Tests, realdotnet msbuild -t:ComputeRunArgumentsagainst a generated AppHost withAspireCliPathin the environment):ComputeRunArgumentsWarnsWhenAmbientAspireCliPathOverridesDnxMode(Dnx,DnxPinned,dNxPiNnEd): 3/3 fail before (noASPIRE015in output), pass after. They also assert that the resolved mode is stillAspireand thatRunCommandis still the configured path.ComputeRunArgumentsDoesNotWarnWhenAspireCliPathDoesNotOverrideDnxMode(Pathmode;DnxPinnedwithNoWarn=ASPIRE015): passes before and after.Aspire.Hosting.Sdk.Testslocally after the renumber and merge withmain: 103 passed, 0 failed (3 Windows-only skipped).NoWarnhandling instead of an explicit check in the warning condition;_AspireUseDnxCliRunHookrenamed to_AspireCliInvocationModeRequestsDnx): theNoWarn=ASPIRE015case still passes, and the fullAspire.Hosting.Sdk.Testsrun passes locally (119 passed, 0 failed, 4 platform-specific skips).E2E with a real AppHost and the Aspire CLI (Linux,
playground/CustomResources/CustomResources.AppHosttemporarily set to<AspireCliInvocationMode>DnxPinned</AspireCliInvocationMode>, withAspireCliPath=<aspire.cli 13.6.4>in the environment, as the VS Code extension sets it, thendotnet run):Before (main): the CLI from
AspireCliPathruns the AppHost, with no diagnostic:After: same launch (precedence unchanged), and the override is now visible:
Following the warning's advice (adding
<AspireCliPath></AspireCliPath>to the playground project, with the environment variable still set) resolves_AspireResolvedCliInvocationMode=Dnxand emits noASPIRE015. The playground change was local proof only and is not committed: pinning the in-repo playground toDnxPinnedwould make it request an unpublishedaspire.clidev version.Checklist
🤖 Posted by AspireAgent (AI Agent)