Fix nuget subcommand --help forwarding to NuGet CLI#53723
Merged
marcpopMSFT merged 5 commits intomainfrom Apr 17, 2026
Merged
Conversation
The condition `command.GetRootCommand() is NuGetCommandDefinition` was always false because `GetRootCommand()` traverses all the way up to `DotNetCommandDefinition` (the actual root), not to `NuGetCommandDefinition`. Replace it with `IsInNuGetCommandTree(command)` which correctly traverses the parent chain to check if the command is within the NuGet subtree. Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/f678f3d7-f807-4a5a-9900-e20baeb4a0a0 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix help output for dotnet nuget add source
Fix nuget subcommand --help forwarding to NuGet CLI
Apr 6, 2026
Member
|
Confirmed locally. Tested in codespaces with a few different nuget commands and it works well there. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in the .NET 11 SDK where dotnet nuget <subcommand> --help displayed generic System.CommandLine help instead of forwarding to the NuGet CLI help output.
Changes:
- Replaces the incorrect
GetRootCommand()-based NuGet detection with an ancestor traversal (IsInNuGetCommandTree). - Ensures NuGet help forwarding triggers for both registered and unregistered (unmatched-token) NuGet subcommand paths.
baronfel
approved these changes
Apr 10, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
MiYanni
requested changes
Apr 13, 2026
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/ecbcb5ee-0e5d-4627-8793-f8d210628bc0 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
auto-merge was automatically disabled
April 14, 2026 17:59
Head branch was pushed to by a user without write access
marcpopMSFT
approved these changes
Apr 14, 2026
This was referenced Apr 16, 2026
MiYanni
approved these changes
Apr 16, 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.
Fixes #53673
dotnet nuget add source --help(and all nuget subcommand help) showed the generic System.CommandLine help for thenugetcommand instead of forwarding to the NuGet CLI. Regression in 11.0 SDK.Root Cause
DotnetHelpBuilder.Write()used this guard to detect NuGet commands:GetRootCommand()traverses all the way to the actual CLI root (DotNetCommandDefinition), so this check is alwaysfalse. The code falls through tobase.Write(context), showing the generic System.CommandLine help for thenugetcommand.Fix
Replace the broken check with a proper ancestor traversal:
This correctly handles all cases:
nuget add source(where the matched command isNuGetCommandDefinitionitself, with unmatched tokens)NuGetDeleteCommandDefinition, etc.)NuGetTrustAuthorCommandDefinition, etc.)