Skip to content

Fail promptly when dotnet run launches an AppHost in publish mode - #21065

Merged
Damian Edwards (DamianEdwards) merged 2 commits into
mainfrom
damianedwards-resource-restart-investigation
Oct 16, 2026
Merged

Damian Edwards (DamianEdwards) merged 2 commits into
mainfrom
damianedwards-resource-restart-investigation

Conversation

@DamianEdwards

Copy link
Copy Markdown
Member

Description

dotnet run --operation publish delegates to aspire run when the CLI run hook is enabled, but starts the AppHost in publish mode. The CLI waits for dashboard readiness while publishing never starts the dashboard and expects a publishing client to consume progress and request shutdown. This leaves the command stuck at Starting dashboard....

Reject the dashboard-readiness RPC when the AppHost's effective execution mode is publish, returning guidance to use aspire publish. Checking the effective mode also covers legacy --publisher manifest and configuration-based invocation. The check runs before the dashboard-disabled shortcut so disabling the dashboard cannot hide the mismatch. Normal publishing does not call this RPC and remains unchanged.

Adds regression coverage and contributor guidance.

User-facing usage

dotnet run --project .\playground\Redis\Redis.AppHost\ --operation publish

Now exits with code 2 and reports:

An unexpected error occurred: The AppHost is in publish mode and cannot be started with 'aspire run'. Use 'aspire publish' instead.

Validation

  • dotnet test --project .\tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class "Aspire.Hosting.Backchannel.AppHostRpcTargetTests" --filter-class "Aspire.Hosting.Backchannel.AppHostBackchannelTests" --filter-class "Aspire.Hosting.Tests.OperationModesTests" --filter-class "Aspire.Hosting.Tests.Publishing.PipelineExecutorTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" - passed, 24 tests. The six new publish-mode cases failed before the fix. Existing NU1902/NU1903 package audit warnings were reported.
  • dotnet build .\playground\Redis\Redis.AppHost\Redis.AppHost.csproj -v:q /p:SkipNativeBuild=true - passed.
  • dotnet run --project .\playground\Redis\Redis.AppHost\ -p:_AspireTasksAssembly="$PWD\artifacts\bin\Aspire.Hosting.Tasks\Debug\net10.0\Aspire.Hosting.Tasks.dll" --operation publish - reproduced the hang before the fix; after the fix, exited with code 2 and the guidance above. The task-assembly override is needed for this source-build workspace.
  • aspire do publish-manifest --project .\playground\Redis\Redis.AppHost\Redis.AppHost.csproj --no-build --output-path <scratch> --non-interactive - passed with CLI 13.6.1 against the fixed AppHost; generated the manifest and all four pipeline steps succeeded. _AspireTasksAssembly was set to the source-built task assembly.

Fixes #18946

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Reject dashboard readiness requests in publish mode with guidance to use aspire publish. Cover effective operation configuration and disabled dashboards.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bd0dfb5d-566e-4711-8011-8ca4a20398d8
@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 -- 21065

Or

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

@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 16, 2026
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot October 16, 2026 20:17
Move user-facing guidance into Hosting message resources and update generated localization inputs and regression assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bd0dfb5d-566e-4711-8011-8ca4a20398d8

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

The narrowly scoped guard has focused regression coverage and reported scenario validation, with no unresolved blocking issues.

0 open findings

What changed in this PR

Fixes #18946 by rejecting dashboard-readiness requests when an AppHost is in publish mode, preventing dotnet run --operation publish from hanging.

Changes:

  • Adds an effective-mode guard with guidance to use aspire publish.
  • Covers publish-mode variants and dashboard-disabled behavior with regression tests.
  • Adds localization entries and contributor guidance.
File Description
tests/​Aspire.Hosting.Tests/​Backchannel/​AppHostRpcTargetTests.cs Adds regression coverage.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.zh-Hant.xlf Adds Traditional Chinese localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.zh-Hans.xlf Adds Simplified Chinese localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.tr.xlf Adds Turkish localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.ru.xlf Adds Russian localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.pt-BR.xlf Adds Brazilian Portuguese localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.pl.xlf Adds Polish localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.ko.xlf Adds Korean localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.ja.xlf Adds Japanese localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.it.xlf Adds Italian localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.fr.xlf Adds French localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.es.xlf Adds Spanish localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.de.xlf Adds German localization placeholder.
src/​Aspire.Hosting/​Resources/​xlf/​MessageStrings.cs.xlf Adds Czech localization placeholder.
src/​Aspire.Hosting/​Resources/​MessageStrings.resx Defines the actionable error message.
src/​Aspire.Hosting/​Resources/​MessageStrings.Designer.cs Exposes the message resource accessor.
src/​Aspire.Hosting/​Backchannel/​AppHostRpcTarget.cs Rejects dashboard readiness in publish mode.
docs/​contributing.md Directs publishing users to aspire publish.
Files not reviewed (1)
  • src/Aspire.Hosting/Resources/MessageStrings.Designer.cs: Generated file

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

53 / 99 PR test projects · 4 PR jobs, from 17 changed files.

Selected PR test projects (53 / 99)

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.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.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.RemoteHost.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, Aspire.Templates.Tests, Infrastructure.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 46 of the 53 selected test projects come from a single change — src/Aspire.Hosting/Backchannel/AppHostRpcTarget.cs.

🔧 src/Aspire.Hosting/Backchannel/AppHostRpcTarget.cs (changed source)
→ 46 via the project graph

show 46

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.EntraId.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/Backchannel/AppHostRpcTargetTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Hosting.Dotnet
→ 2 tests: Aspire.Cli.EndToEnd.Tests, Aspire.Templates.Tests

📦 affected project Aspire.Hosting
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Hosting/Resources/MessageStrings.resx (changed source)
→ 1 directly: Infrastructure.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.Dotnet
extension-e2e • src/Aspire.Hosting/Backchannel/AppHostRpcTarget.cs, src/Aspire.Hosting/Resources/MessageStrings.Designer.cs, src/Aspire.Hosting/Resources/MessageStrings.resx, src/Aspire.Hosting/Resources/xlf/MessageStrings.cs.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.de.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.es.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.fr.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.it.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.ja.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.ko.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.pl.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.pt-BR.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.ru.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.tr.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.zh-Hans.xlf, src/Aspire.Hosting/Resources/xlf/MessageStrings.zh-Hant.xlf
• affected project Aspire.Hosting
polyglot • affected project Aspire.Hosting
• affected project Aspire.Hosting.Azure.Provisioning.KeyVault
typescript-api-compat affected project Aspire.Hosting

Selection computed for commit 86131e6.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@DamianEdwards
Damian Edwards (DamianEdwards) merged commit 7f11155 into main Oct 16, 2026
658 of 662 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 16, 2026
aspire-repo-bot Bot added a commit to microsoft/aspire.dev that referenced this pull request Oct 16, 2026
…ublish

Documents microsoft/aspire#21065: dotnet run --operation publish now fails
fast with a clear error instead of hanging at dashboard startup when the
CLI run hook is enabled. Adds a troubleshooting entry and a cross-reference
note in the Aspire SDK docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1902

Generated by PR Documentation Check · copilot · auto · 83.3 AIC · ⌖ 20.1 AIC · ⊞ 20.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

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

Triggered signals: pr_body_has_cli_flag_mention (PR body mentions --operation publish), pr_body_has_user_facing_section (PR body has a "User-facing usage" section showing the new exit code 2 and error message). Added a new "dotnet run --operation publish hangs at Starting dashboard..." troubleshooting entry in get-started/troubleshooting.mdx explaining the cause and showing the new fail-fast error message, plus a cross-reference caution note in get-started/aspire-sdk.mdx's "Running with dotnet run" section pointing users to aspire publish instead.

Note

This draft PR needs human review before merging.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

dotnet run --operation publish should exit on failure

3 participants