Repository navigation
[release/10.0.4xx] Fix NuGet subcommand help forwarding - #55482
Merged
Merged
Conversation
Backport of #53723. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 0048e77e-e810-4e6b-92ec-66f3a79ca171
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dotnet nuget subcommand --help handling so help output is forwarded to the NuGet CLI (instead of showing generic System.CommandLine help), by correctly detecting when the current command is within the NuGet command subtree.
Changes:
- Replace the incorrect
GetRootCommand()-based NuGet detection with an ancestor traversal (IsInNuGetCommandTree). - Add
IsInNuGetCommandTree(Command)helper to walkParentsand identify NuGet command ancestry.
Member
Author
|
/tactics |
akoeplinger
approved these changes
Jul 29, 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.
Backport of #53723 to release/10.0.4xx.
The NuGet help override checked
GetRootCommand(), which returns the dotnet root rather than the NuGet ancestor. Walk the parent command chain instead so commands such asdotnet nuget add source --helpforward to the NuGet CLI.Tactics
Summary
The
DotnetHelpBuilder.Write()method usedcommand.GetRootCommand() is NuGetCommandDefinitionto detect when a command is part of the NuGet subtree. BecauseGetRootCommand()always traverses all the way to the CLI root (DotNetCommandDefinition), this check always evaluates tofalse, causing all NuGet subcommand help (e.g.,dotnet nuget add source --help) to display the generic System.CommandLine help instead of forwarding to the NuGet CLI. The fix replaces this broken check with a recursive ancestor walk (IsInNuGetCommandTree) insrc/Cli/dotnet/Parser.cs, which correctly handles the rootNuGetCommandDefinition, direct subcommands, and deeply nested subcommands. This is a minimal, targeted fix with no behavioral changes outside the NuGet help path.Customer Impact
Users running
dotnet nuget <subcommand> --help(e.g.,dotnet nuget add source --help,dotnet nuget trust author --help) in affected SDK versions receive generic, unhelpful System.CommandLine output instead of the NuGet-specific help text. This affects all users of NuGet subcommands on the impacted SDK. The regression was introduced in the 11.0 SDK (per the original PR #53723) and is now being backported torelease/10.0.4xx. There is no known simple workaround; users must rundotnet nuget --helpand navigate manually, or consult online documentation.Regression?
Yes — worked in 10.0.300 and below.
Testing
The fix is validated by the original PR #53723, which included the root-cause analysis and fix. CI pipelines have been triggered for this backport PR (Azure Pipelines run confirmed in PR comments). No additional manual repro steps or new unit tests are described in the backport PR itself beyond what was covered upstream.
Risk
Low. The change modifies a single file (
src/Cli/dotnet/Parser.cs), adding 15 lines and removing 1. It is scoped entirely to the NuGet help-forwarding path and does not affect build, restore, publish, or any other SDK functionality. The fix was already validated in the main branch via #53723.