Route error-context DisplayMessage calls to stderr in BaseCommand#17231
Conversation
…ride Add an optional ConsoleOutput? consoleOverride parameter to DisplayMessage and DisplayCancellationMessage so callers can explicitly route output to a specific stream. When null, the existing MessageConsole default is used. In BaseCommand, the 'see logs at' messages displayed on non-zero exit codes and the cancellation message now pass ConsoleOutput.Error so they appear on stderr alongside the error itself. Refactored ConsoleInteractionService to use GetConsoleOutput/GetLogger helper methods, eliminating duplicated resolution logic.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17231Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17231" |
There was a problem hiding this comment.
Pull request overview
Routes error-context messages (log file paths shown on non-zero exit, and the cancellation message when exit is non-success) to stderr in BaseCommand, by adding an optional ConsoleOutput? consoleOverride parameter to DisplayMessage and DisplayCancellationMessage on IInteractionService. Also refactors ConsoleInteractionService to share console/logger resolution via GetConsoleOutput/GetLogger helpers.
Changes:
- Add optional
consoleOverrideparameter toIInteractionService.DisplayMessage/DisplayCancellationMessageand propagate it throughConsoleInteractionServiceandExtensionInteractionService. - In
BaseCommand, passConsoleOutput.Errorfor the "see logs at" messages on failure and for the cancellation message when exit code is non-success. - Update all test/mock implementations of
IInteractionServiceto match the new signatures.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Cli/Interaction/IInteractionService.cs | Adds optional consoleOverride parameter to two interface methods. |
| src/Aspire.Cli/Interaction/ConsoleInteractionService.cs | Implements the override via GetConsoleOutput/GetLogger helpers. |
| src/Aspire.Cli/Interaction/ExtensionInteractionService.cs | Forwards consoleOverride to inner console service. |
| src/Aspire.Cli/Commands/BaseCommand.cs | Routes failure-context messages and cancellation to stderr. |
| tests/Aspire.Cli.Tests/TestServices/TestInteractionService.cs | Updates mock signatures. |
| tests/Aspire.Cli.Tests/TestServices/TestExtensionInteractionService.cs | Updates mock signatures. |
| tests/Aspire.Cli.Tests/Templating/DotNetTemplateFactoryTests.cs | Updates mock signatures. |
| tests/Aspire.Cli.Tests/Projects/ExtensionGuestLauncherTests.cs | Updates mock signatures. |
| tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs | Forwards consoleOverride in delegating mock. |
| tests/Aspire.Cli.Tests/Commands/PublishCommandPromptingIntegrationTests.cs | Updates mock signatures. |
|
Re-running the failed jobs in the CI workflow for this pull request because 2 jobs were identified as retry-safe transient failures in the CI run attempt.
|
|
❓ CLI E2E Tests unknown — 90 passed, 0 failed, 1 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26076550107 |
|
✅ No documentation update needed. docs_optional → No signals triggered (signal_count == 0). The PR is an internal bug fix that routes error-context messages (e.g., "see logs at..." and cancellation messages) from stdout to stderr in |
Description
Error-context messages in
BaseCommand(log file paths shown on failure, cancellation message) were written to stdout by default. This made them invisible when users redirected stdout, and they intermixed with structured output (e.g., JSON).This PR adds an optional
ConsoleOutput? consoleOverrideparameter toDisplayMessageandDisplayCancellationMessageonIInteractionService. When provided, output routes to the specified stream regardless of the currentConsoleproperty. Whennull, existing behavior is preserved.In
BaseCommand, the "see logs at" messages and the cancellation message now passConsoleOutput.Errorso they appear on stderr alongside the error itself — consistent with theDisplayErrorbehavior established in #17230.Also refactors
ConsoleInteractionServiceto useGetConsoleOutput/GetLoggerhelper methods, eliminating duplicated console resolution logic.Fixes #16136
Checklist