[WIP] dotnet first-run text negatively impacts completion script generation
#50224
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.
completeandcompletions)Program.csConfigureDotNetForFirstTimeUsemethodIssue: When users run
dotnet completions script <shell>ordotnet completecommands to generate shell completion scripts, the first-run experience messages are printed to stdout, corrupting the shell completion scripts.Root cause: The
ConfigureDotNetForFirstTimeUsemethod inProgram.csruns for all commands and prints welcome messages to stdout via theDotnetFirstTimeUseConfigurer.Solution: Added an
IsCompletionCommand()method that identifies completion-related commands (completeandcompletions) and skips the first-run experience for them by settingskipFirstTimeUseCheck=true.Testing:
dotnet completions script bash- no first-run messages, clean script outputdotnet complete "dotnet completions "- no first-run messages, clean completion outputdotnet build --help- first-run messages appear correctly for regular commandsdotnet --version- continues to work without first-run (existing behavior)The fix is minimal and surgical, affecting only the specific commands that generate completion scripts while preserving the first-run experience for all other commands.
Fixes #50065.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.