microsoft / microsoft/aspire

Invalid AspireCliInvocationMode values are silently ignored

Open
#19,714 1 comment 0 reactions 0 assignees View on GitHub
area-cli triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Description

`AspireCliInvocationMode` accepts invalid values silently. A misspelled or unsupported value is ignored/falls back to Aspire CLI resolution without any warning or error.

This makes configuration mistakes difficult to spot. For example, `DnxPinnedd` or `DefinitelyInvalid` does not fail validation and does not emit a warning; the SDK simply resolves the normal Aspire CLI path instead of DNX.

This is separate from explicit `AspireCliPath` precedence. The behavior below was confirmed with `AspireCliPath` cleared both as an environment variable and as an MSBuild property.

### Reproduction

In a generic AppHost project using `Aspire.AppHost.Sdk/13.5.1`, set or pass an invalid invocation mode:

```powershell
$env:AspireCliPath = ''
$env:ASPIRE_CLI_PATH = ''

dotnet msbuild app/Sample.AppHost/Sample.AppHost.csproj `
/t:_ResolveAspireCliInvocation `
/v:diag `
/p:AspireUseCliBundle=true `
/p:AspireCliInvocationMode=DefinitelyInvalid `
/p:AspireCliPath= `
/nologo |
Select-String -Pattern 'AspireCliInvocationMode=|AspireCliPath=|Aspire CLI invocation selection:'
```

Observed result:

```text
Task Parameter:AspireCliInvocationMode=DefinitelyInvalid
Aspire CLI invocation selection: Aspire (aspire: C:\Users\\.aspire\bin\aspire.exe, dnx: C:\Program Files\dotnet\dnx.cmd)
```

Running the validation target also succeeds:

```powershell
$env:AspireCliPath = ''
$env:ASPIRE_CLI_PATH = ''

dotnet msbuild app/Sample.AppHost/Sample.AppHost.csproj `
/t:_ValidateAspireCliDnxInvocationMode `
/v:normal `
/p:AspireUseCliBundle=true `
/p:AspireCliInvocationMode=DefinitelyInvalid `
/p:AspireCliPath= `
/nologo
```

Observed result:

```text
Build succeeded.
0 Warning(s)
0 Error(s)
```

Diagnostic output confirms the invalid property value was present:

```text
AspireCliInvocationMode = DefinitelyInvalid
```

### Expected behavior

The SDK should warn or error when `AspireCliInvocationMode` is set to an unsupported value.

For example, if the supported values are `Path`, `Dnx`, and `DnxPinned`, then a value like `DefinitelyInvalid` should produce a diagnostic explaining the accepted values.

### Actual behavior

Invalid values are accepted silently. They do not produce a warning, error, or validation diagnostic, and resolution falls back to Aspire CLI mode.

### Environment

- OS: Windows
- .NET SDK: 10.0.303
- AppHost SDK: `Aspire.AppHost.Sdk/13.5.1`

Contributor guide

Open the contributing guide

Research direction

Start by locating the MSBuild targets or entry points named _ResolveAspireCliInvocation and _ValidateAspireCliDnxInvocationMode, then reproduce the invalid-value case with the commands in the issue. Done means unsupported AspireCliInvocationMode values produce a warning or error that lists accepted values instead of silently selecting Aspire CLI mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.