Repository navigation
Change NuGetCommands.Add to accept Command instead of RootCommand - #7466
Merged
Merged
Conversation
- Change `NuGetCommands.Add` to accept `Command` instead of `RootCommand` - Remove 2 redundant backcompat overloads that were marked for deletion - Update PublicAPI files to reflect the new API surface
Copilot
AI
changed the title
[WIP] Update NuGet commands to only require Command
Change NuGetCommands.Add to accept Command instead of RootCommand
Jun 9, 2026
nkolev92
reviewed
Jun 9, 2026
nkolev92
reviewed
Jun 9, 2026
Both the new Command overload and the shipped RootCommand overload had IVirtualProjectBuilder? = null, violating RS0026 (multiple overloads with optional params) and RS0027 (optional-param overload must have the most params). Fix: remove = null from both 3-param overloads, making virtualProjectBuilder a required (nullable) param. Binary compat is preserved since the method signature is identical; source compat is preserved via the existing 2-param and 0-param RootCommand backcompat overloads. Update PublicAPI.Shipped.txt accordingly.
nkolev92
reviewed
Jun 9, 2026
nkolev92
approved these changes
Jun 9, 2026
zivkan
approved these changes
Jun 10, 2026
Nigusu-Allehu
approved these changes
Jun 10, 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: NuGet/Home#14939
Description
NuGetCommands.Addrequired aRootCommanddespite not using anyRootCommand-specific features —RootCommandis just aCommandsubclass. This unnecessarily prevented the dotnet CLI from passing non-root command instances.NuGetCommands.cs: Added a new primaryAddoverload acceptingCommand; kept the existingRootCommandoverloads as backcompat shims that delegate to the newCommandoverload (to be removed once the SDK has switched over)PublicAPI.Shipped.txt: Retained the 2-param and 3-paramRootCommandentries; removed the 1-paramRootCommandentryPublicAPI.Unshipped.txt: Added the newCommand-based overloadSince
RootCommandderives fromCommand, existing callers passing aRootCommandinstance continue to work without modification via the backcompat overloads.PR Checklist