Skip to content

Warn on unsupported AspireCliInvocationMode values - #21545

Merged
David Fowler (davidfowl) merged 2 commits into
mainfrom
davidfowl/fix-19714-invalid-invocation-mode
Nov 7, 2026
Merged

David Fowler (davidfowl) merged 2 commits into
mainfrom
davidfowl/fix-19714-invalid-invocation-mode

Conversation

@davidfowl

Copy link
Copy Markdown
Collaborator

Description

AspireCliInvocationMode only recognized Dnx and DnxPinned; every other value (for example DnxPinnedd or DefinitelyInvalid) silently fell through to Path resolution, so typos never surfaced.

Root cause: _ResolveAspireCliInvocation passed the raw value to ResolveAspireCliInvocation, which treats anything other than Dnx/DnxPinned as Path. The only validation target (_ValidateAspireCliDnxInvocationMode) is conditioned on a DNX mode, so it was skipped for unrecognized values.

Fix: _ResolveAspireCliInvocation emits a new suppressible ASPIRE014 warning when the value is not Path, Dnx or DnxPinned (case-insensitive), and resolution continues in Path mode as before. I chose a warning instead of an error so that existing builds keep working while the mistake becomes visible. ASPIRE013 is skipped because open PRs #21288 and #19880 both propose it. docs/list-of-diagnostics.md documents ASPIRE014.

Fixes #19714

Before (main)

Playground DotnetProject.AppHost with -p:AspireUseCliBundle=true -p:AspireCliInvocationMode=DefinitelyInvalid -t:_ResolveAspireCliInvocation -v:diag:

Task Parameter:AspireCliInvocationMode=DefinitelyInvalid
Aspire CLI invocation selection: Dnx (aspire: , dnx: /root/aspire/.dotnet/dnx)   <- Path-mode fallback (no aspire on PATH)
    0 Error(s)
    0 Warning(s)

A full dotnet build of the AppHost with the same value also reported 0 Warning(s).

After

Aspire.Hosting.AppHost.in.targets(221,5): warning ASPIRE014: DotnetProject.AppHost is configured with AspireCliInvocationMode=DefinitelyInvalid, which is not a supported value. Supported values are Path, Dnx, and DnxPinned. The default Path invocation mode will be used.
Aspire CLI invocation selection: Dnx (aspire: , dnx: /root/aspire/.dotnet/dnx)
    0 Error(s)
    1 Warning(s)

Valid values (Path, DnxPinned) still resolve to Aspire and Dnx without a warning.

End-to-end with Aspire

I ran dotnet run on playground/DotnetProject/DotnetProject.AppHost with AspireCliInvocationMode=DefinitelyInvalid and the Aspire CLI built from this branch (17.0.0-dev) on PATH. The warning appears during the build, and the AppHost then launches through aspire run (Path mode):

Building...
...Aspire.Hosting.AppHost.in.targets(221,5): warning ASPIRE014: DotnetProject.AppHost is configured with AspireCliInvocationMode=DefinitelyInvalid, which is not a supported value. Supported values are Path, Dnx, and DnxPinned. The default Path invocation mode will be used.
Connecting to AppHost...
Starting dashboard...
     AppHost:  DotnetProject.AppHost.csproj
               Press CTRL+C to stop the AppHost and exit.

(The dashboard was skipped locally with SkipDashboardProjectReference=true.)

Tests

New tests in tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs:

  • ComputeRunArgumentsWarnsAndUsesPathModeWhenInvocationModeIsUnsupported (DefinitelyInvalid, DnxPinnedd): asserts that ASPIRE014 is emitted and that the fake aspire from PATH is selected.
  • ComputeRunArgumentsDoesNotWarnWhenInvocationModeIsSupported (unset, Path, pAtH, Dnx, DnxPinned).
  • UnsupportedInvocationModeWarningCanBeSuppressed (NoWarn=ASPIRE014).

Without the fix, the two unsupported-value cases fail (total: 8, failed: 2). With the fix, the full Aspire.Hosting.Sdk.Tests project passes: 98 total, 94 passed, 0 failed, 4 skipped (Windows-only).

Playground

No playground file changed. In-repo playground AppHosts don't import Aspire.Hosting.AppHost.props, so AspireUseCliBundle isn't enabled by default and the packaged tasks assembly isn't present. Setting AspireCliInvocationMode in a playground project would therefore have no effect in a normal repo build. The playground proof above runs the existing DotnetProject.AppHost and passes those properties on the command line.

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)

Unsupported values were silently treated as Path. Emit ASPIRE014 from
_ResolveAspireCliInvocation so misspelled modes such as DnxPinnedd are visible.

Fixes #19714

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

Or

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

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot October 31, 2026 07:32
@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.

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 recorded for the invocation-mode warning and fallback changes.

No open issues 🎉

What changed in this PR

Addresses #19714 by warning about unsupported AspireCliInvocationMode values in AppHost CLI resolution while preserving the existing Path fallback behavior.

Changes:

  • Adds suppressible warning ASPIRE014 for values other than Path, Dnx, or DnxPinned, ignoring case.
  • Adds tests for invalid values, supported values, fallback resolution, and warning suppression.
  • Documents the new diagnostic and fallback behavior.
File Description
tests/​Aspire.Hosting.Sdk.Tests/​AppHostSdkTargetsTests.cs Adds validation, fallback, and suppression tests.
src/​Aspire.Hosting.AppHost/​build/​Aspire.Hosting.AppHost.in.targets Emits ASPIRE014 for unsupported invocation modes.
docs/​list-of-diagnostics.md Documents ASPIRE014 and the default Path fallback.

Review effort: Balanced

Copy link
Copy Markdown
Collaborator Author

CI note: Tests / No-package tests (Aspire.Hosting.Tests, Hosting-1) (windows-latest) failed because the hosted runner lost communication with the server. That is an infrastructure failure: no test failure was reported, and this PR changes only the AppHost SDK targets and SDK tests. I reran that job once. All 285 other checks passed on head 2df6867.

🤖 Posted by AspireAgent (AI Agent)

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 31, 2026 08:32
David Fowler (davidfowl) added a commit that referenced this pull request Nov 6, 2026
#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>
@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 added the ASPIRE013 row and rewrote the CLI-bundle paragraph. I kept main's version, added this PR's ASPIRE014 row after ASPIRE013, and appended this PR's sentence about unsupported AspireCliInvocationMode values. The targets and test files merged without conflicts.

ASPIRE014 is still free. It isn't used on main, and no other open PR adds it. #21592 uses ASPIRE015 to avoid this ID.

Local tests: AppHostSdkTargetsTests passed 95, failed 0 and skipped 4 (Windows-only or conditional). The run included the new ASPIRE014 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:41
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Tests selector

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

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 on unsupported invocation modes while preserving the existing Path-mode fallback.

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.

No confirmed issues found in review.

@davidfowl
David Fowler (davidfowl) merged commit 7b48978 into main Nov 7, 2026
310 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 7, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2085

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

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

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

Documents new ASPIRE014 warning. Triggered signal diagnostic_documentation_changed (evidence: docs/list-of-diagnostics.md). Adds diagnostics/aspire014.mdx, an overview table row, a sidebar entry, and a note in get-started/aspire-sdk.mdx.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid AspireCliInvocationMode values are silently ignored

3 participants