Fix dotnet remove package project argument not recognized - #53401
#53401Merged
martinrrm merged 1 commit intoMar 12, 2026
maindotnet/sdk:mainfrom
dev-martinrrm-fix-dotnet-remove-package-workingdirdotnet/sdk:dev-martinrrm-fix-dotnet-remove-package-workingdirCopy head branch name to clipboard
Merged
Fix dotnet remove package project argument not recognized#53401martinrrm merged 1 commit intomaindotnet/sdk:mainfrom dev-martinrrm-fix-dotnet-remove-package-workingdirdotnet/sdk:dev-martinrrm-fix-dotnet-remove-package-workingdirCopy head branch name to clipboard
martinrrm merged 1 commit into
maindotnet/sdk:mainfrom
dev-martinrrm-fix-dotnet-remove-package-workingdirdotnet/sdk:dev-martinrrm-fix-dotnet-remove-package-workingdirCopy head branch name to clipboard
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression where dotnet remove <project> package <name> fails to recognize the positional project/file argument, causing “could not find any project” when invoked from outside the project directory. This aligns dotnet remove package behavior with the existing path-resolution logic used by other package commands.
Changes:
- Wire the positional
<PROJECT | FILE>argument intoPackageRemoveCommandpath processing (matching thePackageAddCommandpattern). - Extend
PackageRemoveCommandDefinitionBasewith aGetProjectOrFileArgument()hook so hiddendotnet remove packagecan reuse the parent command’s positional argument. - Add a regression test covering
dotnet remove <relative project path> package <package>.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs | Adds coverage for removing a package when the project is provided positionally via a relative path. |
| src/Cli/dotnet/Commands/Package/Remove/PackageRemoveCommand.cs | Passes the positional project/file argument into ProcessPathOptions so the command resolves the intended project. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Package/PackageRemoveCommandDefinition.cs | Introduces GetProjectOrFileArgument() on the remove command definition base (returns null for dotnet package remove). |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Hidden/Remove/RemovePackageCommandDefinition.cs | Supplies the parent RemoveCommandDefinition.ProjectOrFileArgument so hidden dotnet remove package honors the positional project/file argument. |
You can also share your feedback on Copilot code review. Take the survey.
jeffkl
approved these changes
Mar 12, 2026
nkolev92
approved these changes
Mar 12, 2026
nkolev92
left a comment
Contributor
There was a problem hiding this comment.
main goes to 11.0.100.
So this will probably need ported to wherever the regression happened.
martinrrm
deleted the
dev-martinrrm-fix-dotnet-remove-package-workingdir
branch
March 12, 2026 16:56
This was referenced Mar 12, 2026
Scrambles56
added a commit
to Givenwell/avro-nuget
that referenced
this pull request
May 3, 2026
The :10.0 floating tag now resolves to SDK 10.0.203, which has a regression in `dotnet remove <proj> package <name>` (returns "Could not find any project") — see dotnet/sdk#53401, port #53418 still unmerged. Pin to the digest used by the last known-good build of Givenwell/Events (run 22832784599) until the fix lands upstream. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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: NuGet/Home#14801
NuGet Product Used
dotnet.exe
Product Version
.NET SDK Version: 10.0.300-preview.26126.103
Worked before?
It is a regression since it doesn’t repro on VS Main/11405.173 + NuGet Client Dev/7.3.0.51.
Impact
It's more difficult to complete my work
Repro Steps & Context
Note:
Repro Steps:
dotnet remove MyApp\MyApp.csproj package NUnitExpected Result:
No error occurs and the package is removed successfully.
Actual Result:
An error ‘could not find any project’ occurs as the red line in the screenshot below.