Skip to content

fix: build the example AppHosts without the Aspire CLI - #56

Merged
kieronlanning merged 1 commit into
mainfrom
fix/aspire-cli-bundle-race
Nov 8, 2026
Merged

kieronlanning merged 1 commit into
mainfrom
fix/aspire-cli-bundle-race

Conversation

@kieronlanning

Copy link
Copy Markdown
Contributor

Problem

The Release packages job failed on:

dotnet build src/ResourceKit.slnx --configuration Release --no-restore
aspire.hosting.apphost/13.6.4/build/Aspire.Hosting.AppHost.targets(433,5):
  error ASPIRE009: Example.AppHost is configured to use the Aspire CLI bundle,
  but the bundle could not be resolved...
  Automatic Aspire CLI bundle setup failed with exit code 1.

The PR run ten minutes earlier had passed that same Release build on the same sources.

Root cause

Both example AppHosts set AspireUseCliBundle=true, which makes a build require a resolvable
DCP/dashboard bundle. With none present, Aspire.Hosting.AppHost.targets runs
dnx aspire.cli@13.6.4 setup once per AppHost, so a single solution build restores and extracts the
same CLI concurrently. Reproduced on Linux with a fresh $HOME/.aspire:

CONCURRENT_A_EXIT=1
Unhandled exception: The process cannot access the file
  '.../aspire.cli/13.6.4/aspire.cli.13.6.4.nupkg' because it is being used by another process.
CONCURRENT_B_EXIT=0

Exit code 1, which MSBuild reports only as ASPIRE009. It is a race, which is why it passed some runs and
failed others. Neither shared pipeline can install the CLI before its own dotnet build
(purview-build.yml has no pre-build hook, and the release action is a composite action), so the build
must not need one.

Change

  • Example.AppHost / Example.ManualAppHost now default AspireUseCliBundle to false (still
    overridable), the Aspire-documented fallback: the AppHost SDK adds
    Aspire.Dashboard.Sdk.<rid> and Aspire.Hosting.Orchestration.<rid> for the build machine's RID.
    Running the AppHosts is unchanged: the built assembly still carries dcpclipath /
    aspiredashboardpath metadata for 13.6.4.
  • The resulting ASPIRE010 is suppressed only while the bundle stays off, and the opt-in remains:
    dotnet build -p:AspireUseCliBundle=true.
  • New ExampleAppHostTests (Repository.UnitTests) fails if either project opts back in.
  • AGENTS.md, docs/wiki/Contributing.md and CHANGELOG.md record the decision.

Verification (no aspire on PATH, empty Aspire home, the CI condition)

  • dotnet build src/ResourceKit.slnx -c Release: succeeded, 0 warnings, 0 errors
  • unit tier /*/*/*/*[Category=Unit]: 100 tests, 0 failed, 5 skipped
  • dotnet csharpier check .: clean (107 files)

Closes the ASPIRE009 failure in https://github.com/purview-dev/aspire-resourcekit/actions/runs/42512003194

Both example AppHosts opted into the Aspire CLI bundle, which makes *building*
an AppHost require a resolvable bundle. With none present,
Aspire.Hosting.AppHost.targets runs `dnx aspire.cli@13.6.4 setup` once per
AppHost, so one solution build restores and extracts the same CLI concurrently:
the losing process dies on the locked NuGet cache file with exit code 1, which
MSBuild reports only as ASPIRE009, "Automatic Aspire CLI bundle setup failed
with exit code 1". That is what failed the release pipeline on sources the PR
pipeline had just built - being a race, it fails some runs and not others.

Neither shared pipeline can install the Aspire CLI before its own `dotnet
build`, so the build must not need one. The examples now default
AspireUseCliBundle to false, the Aspire-documented fallback: the AppHost SDK
adds Aspire.Dashboard.Sdk.<rid> and Aspire.Hosting.Orchestration.<rid>
references for the build machine's RID instead, and running the AppHost
(`dotnet run`, `aspire run`, TUnit.Aspire) is unchanged. The ASPIRE010 that
reports the choice is suppressed while the bundle stays off, and the opt-in
remains available per build as -p:AspireUseCliBundle=true.

ExampleAppHostTests keeps the opt-in out of the project files; AGENTS.md, the
contributing page and the changelog record why.
@kieronlanning
kieronlanning merged commit 4f5818e into main Nov 8, 2026
1 check passed
@kieronlanning
kieronlanning deleted the fix/aspire-cli-bundle-race branch November 8, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant