Fix aspire start failing in VS Code integrated terminal#15980
Fix aspire start failing in VS Code integrated terminal#15980adamint merged 5 commits intomicrosoft:mainfrom
Conversation
When 'aspire start' runs from the VS Code Aspire terminal, the detached child process inherits ASPIRE_EXTENSION_* environment variables, causing it to detect extension mode and delegate back to the extension via StartDebugSessionAsync instead of launching the AppHost. This results in an immediate exit with code 0. Fix: - Strip extension-related env vars from the detached child process in DetachedProcessLauncher (Unix: remove from startInfo.Environment, Windows: build filtered environment block for CreateProcessW) - Add --non-interactive guard in RunCommand to skip extension delegation when running as a child of 'aspire start' - Set isExtensionHost=false in StartCommand so Dashboard URL always shows in 'aspire start' output - Fix column width calculation in RenderAppHostSummary to only include labels that are actually displayed - Add missing KnownConfigNames constants for extension env vars Fixes microsoft#15786
There was a problem hiding this comment.
Pull request overview
Fixes aspire start prematurely exiting when run from the VS Code integrated Aspire terminal by preventing the detached child (aspire run --non-interactive) from being treated as an extension-hosted invocation.
Changes:
- Adds support in
DetachedProcessLauncherto remove specified environment variables from the detached child process (Unix viaProcessStartInfo.Environment, Windows via a filtered Unicode environment block passed toCreateProcessW). - Updates
RunCommandto skip VS Code extension delegation when--non-interactiveis used, and adjusts summary column-width calculation to consider only displayed labels. - Adds missing extension/debug-session env var constants and a unit test covering the
--non-interactivedelegation guard.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs | Adds a regression test ensuring --non-interactive skips extension debug-session delegation. |
| src/Shared/KnownConfigNames.cs | Adds missing constants for extension/debug-session related environment variables. |
| src/Aspire.Cli/Processes/DetachedProcessLauncher.cs | Extends detached process start API with optional env-var removal set. |
| src/Aspire.Cli/Processes/DetachedProcessLauncher.Unix.cs | Removes specified env vars from detached child process environment on Unix. |
| src/Aspire.Cli/Processes/DetachedProcessLauncher.Windows.cs | Builds and passes a filtered Unicode environment block to CreateProcessW when env-var removal is requested. |
| src/Aspire.Cli/Commands/StartCommand.cs | Forces isExtensionHost=false so dashboard URLs are shown even in VS Code terminal. |
| src/Aspire.Cli/Commands/RunCommand.cs | Guards extension delegation with --non-interactive; fixes summary width calculation based on shown labels. |
| src/Aspire.Cli/Commands/AppHostLauncher.cs | Uses env-var removal when spawning the detached aspire run --non-interactive child. |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15980Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15980" |
Preserve DEBUG_SESSION_* values when the detached child CLI is launched from the VS Code Aspire terminal so the AppHost keeps IDE execution and dashboard debug integration. Also address follow-up review issues in StartCommand and the Windows filtered environment block builder. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
JamesNK
left a comment
There was a problem hiding this comment.
2 comments: 1 actionable issue (unused using), 1 informational note (double-null termination is correct as-is).
Description
When
aspire startruns from the VS Code Aspire terminal, the detached child process (aspire run --non-interactive) inheritsASPIRE_EXTENSION_*environment variables from the terminal. This causes the child to detect extension mode and delegate back to the extension viaStartDebugSessionAsyncinstead of launching the AppHost — resulting in an immediate exit with code 0.Root cause:
DetachedProcessLauncher.Start()inherits all parent environment variables, including extension backchannel vars. The child'sRunCommand.ExecuteAsyncseesIsExtensionHost=trueandExtensionDebugSessionId=empty, triggering the early-return delegation path.Fix (two layers):
DetachedProcessLauncher.Start()now accepts an optional set of env var names to remove. On Unix, vars are removed fromProcessStartInfo.Environment. On Windows, a filtered Unicode environment block is built forCreateProcessW.RunCommanddelegation with--non-interactive— When running in non-interactive mode (as the child ofaspire start), skip theStartDebugSessionAsyncearly return.Additional fixes:
StartCommandnow setsisExtensionHost=falseso the Dashboard URL always appears inaspire startoutputRenderAppHostSummarycolumn width calculation only includes labels that are actually displayedKnownConfigNamesconstants for 6 extension-related env vars (ExtensionDebugRunMode,ExtensionCapabilities,DebugSessionPort,DebugSessionToken,DebugSessionServerCertificate,DcpInstanceIdPrefix)Fixes #15786
Checklist