Display wait-for-debugger message in CLI#14936
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14936Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14936" |
There was a problem hiding this comment.
Pull request overview
Adds user-visible feedback when --wait-for-debugger is used, including (in non-detached runs) parsing the AppHost PID from stdout and displaying it in the CLI. Introduces a shared console-message prefix constant so the AppHost and CLI agree on the marker string.
Changes:
- Add
KnownConsoleMessages.AppHostPidPrefixinsrc/Shared/and link it into bothAspire.HostingandAspire.Cli. - Emit the AppHost PID marker from
DistributedApplication.WaitForDebugger()and parse it from CLI-run stdout to show a PID-specific “waiting for debugger” message. - Add a new localized resource string (
WaitingForDebuggerToAttachToAppHostWithPid) across RESX/XLF.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/KnownConsoleMessages.cs | Adds shared console marker constant for PID output parsing. |
| src/Aspire.Hosting/DistributedApplication.cs | Writes PID marker to stdout to support CLI parsing during debugger-wait. |
| src/Aspire.Hosting/Aspire.Hosting.csproj | Links the new shared KnownConsoleMessages.cs into the hosting project. |
| src/Aspire.Cli/Aspire.Cli.csproj | Links the new shared KnownConsoleMessages.cs into the CLI project. |
| src/Aspire.Cli/Projects/AppHostProjectContext.cs | Adds an optional TaskCompletionSource<int> for signaling PID availability. |
| src/Aspire.Cli/Projects/DotNetAppHostProject.cs | Hooks stdout callback to parse PID marker and signal the TCS. |
| src/Aspire.Cli/Commands/RunCommand.cs | Starts backchannel wait and concurrently displays PID-based “waiting for debugger” message when available. |
| src/Aspire.Cli/Commands/StartCommand.cs | Threads --wait-for-debugger into detached launch flow. |
| src/Aspire.Cli/Commands/AppHostLauncher.cs | Shows generic “waiting for debugger” message in detached mode. |
| src/Aspire.Cli/Resources/InteractionServiceStrings.resx | Adds PID-specific waiting message resource. |
| src/Aspire.Cli/Resources/InteractionServiceStrings.Designer.cs | Adds generated accessor for the new PID-specific resource. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.cs.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.de.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.es.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.fr.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.it.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ja.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ko.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pl.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.pt-BR.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.ru.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.tr.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hans.xlf | Adds XLF entry for PID-specific waiting message. |
| src/Aspire.Cli/Resources/xlf/InteractionServiceStrings.zh-Hant.xlf | Adds XLF entry for PID-specific waiting message. |
Files not reviewed (1)
- src/Aspire.Cli/Resources/InteractionServiceStrings.Designer.cs: Language not supported
| // If --wait-for-debugger, display the AppHost PID in the background as soon | ||
| // as it becomes available. Stop waiting if the backchannel connects first. | ||
| if (waitForDebugger && appHostProcessIdCompletionSource is not null) | ||
| { | ||
| _ = DisplayDebuggerWaitMessageAsync(appHostProcessIdCompletionSource.Task, pendingBackchannel); | ||
| } |
There was a problem hiding this comment.
In non-detached RunCommand, the debugger-wait message is only displayed if the PID task completes before the backchannel connects. If PID parsing never succeeds (e.g., output format changes) or the backchannel connects first, there is no visible feedback even though --wait-for-debugger was requested. Consider emitting the existing generic message immediately when waitForDebugger is true (and optionally replacing/augmenting it with the PID-specific message if/when the PID arrives) to match the PR description's fallback behavior.
de0f9f2 to
e85e139
Compare
93601e3 to
27472cd
Compare
27472cd to
a08f81a
Compare
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22659220578 |
Description
When
--wait-for-debuggeris passed, the CLI now displays a visible console message so the user knows the AppHost is paused waiting for a debugger to attach.Previously,
aspire run --wait-for-debuggershowed no feedback in the console — the message was only written to the log file.ExecCommandandPipelineCommandBasealready displayed a message butRunCommand,StartCommand, and the detached flow did not.Changes:
RunCommand(non-detached): Displays "Waiting for debugger to attach to app host process" before the backchannel spinner, matching the existing behavior ofExecCommandandPipelineCommandBase.StartCommand/RunCommand --detach(detached): TheAppHostLaunchernow accepts awaitForDebuggerparameter and displays the same message before launching the child process. BothStartCommandandRunCommand.ExecuteDetachedAsyncpass the flag through.KnownConsoleMessages: Extracts the debugger wait message prefix intosrc/Shared/KnownConsoleMessages.cs, linked into bothAspire.CliandAspire.Hostingso both sides use the same well-known string for the console output written byDistributedApplication.WaitForDebugger().All commands that accept
--wait-for-debuggernow consistently display the message:RunCommand,StartCommand,ExecCommand,PipelineCommandBase(publish/deploy), and the detached launch flow.Checklist