Skip to content

[release/10.0.4xx] Fix NuGet subcommand help forwarding - #55482

Merged
baronfel merged 1 commit into
release/10.0.4xxfrom
baronfel-backport-nuget-help-10-0-4xx
Jul 29, 2026
Merged

baronfel merged 1 commit into
release/10.0.4xxfrom
baronfel-backport-nuget-help-10-0-4xx

Conversation

@baronfel

@baronfel baronfel commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

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 as dotnet nuget add source --help forward to the NuGet CLI.

Tactics

Summary

The DotnetHelpBuilder.Write() method used command.GetRootCommand() is NuGetCommandDefinition to detect when a command is part of the NuGet subtree. Because GetRootCommand() always traverses all the way to the CLI root (DotNetCommandDefinition), this check always evaluates to false, 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) in src/Cli/dotnet/Parser.cs, which correctly handles the root NuGetCommandDefinition, 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 to release/10.0.4xx. There is no known simple workaround; users must run dotnet nuget --help and 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.

Backport of #53723.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0048e77e-e810-4e6b-92ec-66f3a79ca171
Copilot AI review requested due to automatic review settings July 27, 2026 20:48
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 walk Parents and identify NuGet command ancestry.

@baronfel
baronfel requested a review from a team July 27, 2026 20:53
@baronfel baronfel added Area-CLI backport PR that has been backported to a servicing branch labels Jul 27, 2026
@baronfel baronfel added this to the 10.0.4xx milestone Jul 28, 2026
@baronfel

Copy link
Copy Markdown
Member Author

/tactics

@baronfel
baronfel enabled auto-merge (squash) July 29, 2026 14:23
@baronfel
baronfel merged commit 34bb679 into release/10.0.4xx Jul 29, 2026
32 of 34 checks passed
@baronfel
baronfel deleted the baronfel-backport-nuget-help-10-0-4xx branch July 29, 2026 14:24
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 10.0.4xx, 11.0-rc1 Aug 7, 2026
@wtgodbe wtgodbe removed this from the 11.0-rc1 milestone Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-CLI backport PR that has been backported to a servicing branch Servicing-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants