Skip to content

Display wait-for-debugger message in CLI#14936

Merged
JamesNK merged 3 commits intorelease/13.2from
jamesnk/debugger-message
Mar 5, 2026
Merged

Display wait-for-debugger message in CLI#14936
JamesNK merged 3 commits intorelease/13.2from
jamesnk/debugger-message

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Mar 4, 2026

Description

When --wait-for-debugger is 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-debugger showed no feedback in the console — the message was only written to the log file. ExecCommand and PipelineCommandBase already displayed a message but RunCommand, 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 of ExecCommand and PipelineCommandBase.
  • StartCommand / RunCommand --detach (detached): The AppHostLauncher now accepts a waitForDebugger parameter and displays the same message before launching the child process. Both StartCommand and RunCommand.ExecuteDetachedAsync pass the flag through.
  • Shared KnownConsoleMessages: Extracts the debugger wait message prefix into src/Shared/KnownConsoleMessages.cs, linked into both Aspire.Cli and Aspire.Hosting so both sides use the same well-known string for the console output written by DistributedApplication.WaitForDebugger().

All commands that accept --wait-for-debugger now consistently display the message: RunCommand, StartCommand, ExecCommand, PipelineCommandBase (publish/deploy), and the detached launch flow.

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings March 4, 2026 06:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

🚀 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14936

Or

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.AppHostPidPrefix in src/Shared/ and link it into both Aspire.Hosting and Aspire.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

Comment on lines +264 to +269
// 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);
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@JamesNK JamesNK force-pushed the jamesnk/debugger-message branch from de0f9f2 to e85e139 Compare March 4, 2026 07:12
@JamesNK JamesNK force-pushed the jamesnk/debugger-message branch from 93601e3 to 27472cd Compare March 4, 2026 07:17
@JamesNK JamesNK force-pushed the jamesnk/debugger-message branch from 27472cd to a08f81a Compare March 4, 2026 07:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit b73bc6b:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ❌ Upload failed
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22659220578

@JamesNK JamesNK merged commit 61b1572 into release/13.2 Mar 5, 2026
384 checks passed
@JamesNK JamesNK deleted the jamesnk/debugger-message branch March 5, 2026 00:58
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 5, 2026
eerhardt pushed a commit to eerhardt/aspire that referenced this pull request Mar 7, 2026
Copilot AI pushed a commit that referenced this pull request Mar 10, 2026
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.

3 participants