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.

Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Nov 10, 2026
## 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`:

```text
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

```text
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):

```text
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?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 7b48978)
Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Nov 10, 2026
## 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`:

```text
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

```text
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):

```text
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?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 7b48978)
Ankit Jain (radical) pushed a commit that referenced this pull request Nov 11, 2026
## 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?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

---------

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Maddy Montaquila (maddymontaquila) added a commit to microsoft/aspire.dev that referenced this pull request Nov 17, 2026
ASPIRE014 is a warning, so list it under Warnings next to ASPIRE012.
The warning ships in Aspire 17.1 (microsoft/aspire#21545; the 17.0
backport #22015 was closed), so qualify the SDK bullet and match the
page's quoted message to the targets text.

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

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