Summary
aspire add <pkg> --source <feed> fails on a file-based AppHost
(apphost.cs, as produced by aspire new aspire-empty) with:
❌ Cannot specify option '--source' when operating on a file-based app.
❌ The package installation failed with exit code 5.
The same command on a .csproj AppHost (produced by
aspire new aspire-starter) succeeds. So the user can override the
package feed for a .csproj AppHost but not for a file-based one,
with no in-CLI way to add a package from an arbitrary feed into a
file-based AppHost without hand-editing nuget.config first.
The error string comes from the .NET SDK's
dotnet package add --file … command. Not introduced by any
in-flight PR — the affected code path is unchanged on origin/main
(61d7844655). The dogfood install pattern (aspire new aspire-empty --source <hive> followed by aspire add … --source <hive>) is just the natural way for a user to hit it.
Repro
# Any current CLI; PR #17105's dogfood build (13.4.0-pr.17105.g8b0f3a08)
# was used to reproduce this.
CLI=/path/to/aspire
HIVE=/path/to/hives/<channel>/packages
VER=13.4.0-pr.NNNNN.gXXXXXXXX
# --- A. file-based AppHost: FAILS ---
"$CLI" new aspire-empty \
--name FileBased --output /tmp/fb-test/FileBased \
--source "$HIVE" --version "$VER" \
--localhost-tld false --suppress-agent-init --non-interactive --nologo
"$CLI" add redis \
--apphost /tmp/fb-test/FileBased/apphost.cs \
--source "$HIVE" --version "$VER" \
--non-interactive --nologo
echo "exit=$?"
# --- B. .csproj AppHost: SUCCEEDS ---
"$CLI" new aspire-starter \
--name CsProjBased --output /tmp/cs-test/CsProjBased \
--source "$HIVE" --version "$VER" \
--test-framework None --use-redis-cache false \
--localhost-tld false --suppress-agent-init --non-interactive --nologo
"$CLI" add redis \
--apphost /tmp/cs-test/CsProjBased/CsProjBased.AppHost/CsProjBased.AppHost.csproj \
--source "$HIVE" --version "$VER" \
--non-interactive --nologo
echo "exit=$?"
Expected
aspire add <pkg> --source <feed> should either:
- work the same way on file-based AppHosts as on
.csproj
AppHosts (--source override resolves the package from that feed
and writes the corresponding #:package <name>@<ver> directive
into apphost.cs), or
- fail fast in Aspire CLI itself — before delegating to
dotnet package add — with a message that names --source,
names the file-based AppHost, and tells the user how to achieve
the same effect (e.g. register the feed in the project's
nuget.config).
Either way, behavior must not silently diverge between the two
AppHost shapes.
Actual
File-based path:
Searching for Aspire integrations...
Adding Aspire hosting integration...
❌ Cannot specify option '--source' when operating on a file-based app.
❌ The package installation failed with exit code 5.
CLI exit code: 5 (correctly non-zero — the SDK error is surfaced).
.csproj path with the same arguments:
Searching for Aspire integrations...
Adding Aspire hosting integration...
✅ The package Aspire.Hosting.Redis::13.4.0-pr.17105.g8b0f3a08 was added successfully.
CLI exit code: 0. The AppHost csproj gains:
<PackageReference Include="Aspire.Hosting.Redis" Version="13.4.0-pr.17105.g8b0f3a08" />
Env
Summary
aspire add <pkg> --source <feed>fails on a file-based AppHost(
apphost.cs, as produced byaspire new aspire-empty) with:The same command on a
.csprojAppHost (produced byaspire new aspire-starter) succeeds. So the user can override thepackage feed for a
.csprojAppHost but not for a file-based one,with no in-CLI way to add a package from an arbitrary feed into a
file-based AppHost without hand-editing
nuget.configfirst.The error string comes from the .NET SDK's
dotnet package add --file …command. Not introduced by anyin-flight PR — the affected code path is unchanged on
origin/main(
61d7844655). The dogfood install pattern (aspire new aspire-empty --source <hive>followed byaspire add … --source <hive>) is just the natural way for a user to hit it.Repro
Expected
aspire add <pkg> --source <feed>should either:.csprojAppHosts (
--sourceoverride resolves the package from that feedand writes the corresponding
#:package <name>@<ver>directiveinto
apphost.cs), ordotnet package add— with a message that names--source,names the file-based AppHost, and tells the user how to achieve
the same effect (e.g. register the feed in the project's
nuget.config).Either way, behavior must not silently diverge between the two
AppHost shapes.
Actual
File-based path:
CLI exit code:
5(correctly non-zero — the SDK error is surfaced)..csprojpath with the same arguments:CLI exit code:
0. The AppHost csproj gains:Env
13.4.0-pr.17105.g8b0f3a08(PR feat(cli):aspire doctorlists every Aspire CLI install on the machine #17105 dogfood install)10.0.201