Preserve the default AppHost for explicit runs - #19394
Preserve the default AppHost for explicit runs#19394Adam Ratzman (adamint) wants to merge 14 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 270b31f3-8e18-4d54-ba74-ba62a82630ca
Keep extension and interactive selections persistent while treating direct CLI selections as invocation-scoped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 270b31f3-8e18-4d54-ba74-ba62a82630ca
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19394Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19394" |
There was a problem hiding this comment.
Pull request overview
Makes explicit CLI --apphost selections invocation-scoped while preserving valid configured defaults.
Changes:
- Distinguishes explicit targets from prompted or extension-origin selections.
- Preserves, establishes, or replaces defaults according to selection origin and validity.
- Adds regression tests for each persistence scenario.
Show a summary per file
| File | Description |
|---|---|
src/Aspire.Cli/Projects/ProjectLocator.cs |
Implements selection-aware default preservation. |
tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs |
Covers preservation, replacement, and prompt behavior. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
Ella Hathaway (ellahathaway)
left a comment
There was a problem hiding this comment.
I reviewed the AppHost selection and config-persistence flow end to end, including direct and ambient resolution, detached child launches, the VS Code extension handoff, and the focused regression coverage.
I found two concrete config-persistence issues: one regression in detached ambient launches and one remaining gap for --apphost commands entered in the Aspire terminal.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Adds RunWithExplicitAlternateAppHost_PreservesExistingDefault, which runs `aspire run --apphost Alternate/apphost.cs` against a workspace whose aspire.config.json points at a different AppHost, then asserts the config is byte-for-byte unchanged and no local config was created beside the alternate. The alternate AppHost is patched to write a marker file. Without that, a silent fallback to the configured Primary AppHost would leave the config untouched and pass the persistence assertion vacuously. GetAspireRunCommand now takes optional additional arguments so the new test inherits the ASPIRE_CLI_START_TIMEOUT budget that AspireRunReadyTimeout assumes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
The existing coverage stops on either side of VS Code's two-stage debug configuration resolution: the InteractionService test stubs startDebugging, and the AspireDebugSession tests hand-build a configuration that already carries `explicit-cli`. Neither proves the origin survives the resolver boundary, where ensureAppHostSelectionOrigin backfills an absent origin with `explicit-launch-configuration` and AspireDebugSession then omits `--apphost` for a directory target. The new test runs the real InteractionService, both real resolver stages with a JSON clone between them, and a real AspireDebugSession, asserting the spawned CLI receives `--apphost <directory>` and the explicit-cli origin environment. Reverting the AspireDebugSession condition fails it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
…t-config-persistence
main added a required `vscode.Memento` parameter to AspireDebugConfigurationProvider, so the two-argument construction in the new resolver-stage test no longer compiles against the merged tree. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e30157e-5245-4f06-a696-1516f9cd8f9e
Description
Running
aspire run --apphost <alternate>currently replaces the configuredappHost.path, so the next bareaspire rununexpectedly uses the alternate AppHost.This makes a direct
--apphostselection invocation-scoped when a valid default already exists. Extension user selections and interactive selections from a directory still update the default, while missing or deleted defaults are still established or replaced.Related to #19080, which covered explicit VS Code launch configurations but not direct CLI
--apphostusage.User-facing usage
If
aspire.config.jsonpoints toPrimary/apphost.cs, this runs the secondary AppHost without changing the configured primary AppHost.Validation:
Aspire.Cli.Tests: 5,027 total, 4,993 passed, 34 platform skips, 0 failedAspire.Clibuild: 0 warnings, 0 errorsSecondary/apphost.cs; the config remainedPrimary/apphost.csbefore the run, after startup, and after stoppingFixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?