Lazy initialize Spectre.Console in XPlat command registration#7063
Merged
Lazy initialize Spectre.Console in XPlat command registration#7063
Conversation
Nigusu-Allehu
approved these changes
Jan 20, 2026
nkolev92
approved these changes
Jan 20, 2026
donnie-msft
approved these changes
Jan 20, 2026
martinrrm
approved these changes
Jan 22, 2026
This was referenced Jan 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: dotnet/sdk#52278
Description
This code has already been merged into the dotnet VMR, but NuGet.Client doesn't have a backflow configured for the 10.0.2xx branch: dotnet/dotnet#4139
Spectre.Console's
AnsiConsolewill send VT commands on initialzation, which breaks formatting of other parts of the dotnet CLI when it expects that the terminal has default settings. So, only initialize AnsiConsole when it's about to be used.Tests were not added because testing this is very difficult. You can't test using a child process or redirecting to a file, because Spectre detects that the output is being redirected about avoids sending the VT commands. In order to test, we'd need to P/Invoke operating system specific APIs to open a new PTY. We'd then need all new child process test infrastructure to capture the output. If we just wanted to make sure that the VT command that Spectre sends on init isn't sent, we'd need to first figure out what VT command that is, but then searching for it in the output should be simple enough. However, if we wanted to validate that
dotnet --info's output isn't being malformed, then we'd need to implement a lot of a terminal emulator to figure out what the console output would look like, and then validate there's no leading whitespace on the SDK version number list.PR Checklist
Added testssee description