nuget-cpm-cleaner
1.0.1
dotnet tool install --global nuget-cpm-cleaner --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local nuget-cpm-cleaner --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=nuget-cpm-cleaner&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package nuget-cpm-cleaner --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuget-cpm-cleaner
A .NET global tool that removes unused <PackageVersion> entries from your Directory.Packages.props file (NuGet Central Package Management).
The Problem
When using NuGet CPM, over time packages get removed from .csproj files but their version declarations stay behind in Directory.Packages.props, causing noise and potential confusion.
How It Works
- Locates
Directory.Packages.propsstarting from the specified root (walks up directories if needed) - Parses all
<PackageVersion>entries — the "declared" packages - Recursively scans all
.csprojandDirectory.Build.propsfiles for<PackageReference>entries — the "used" packages - Computes the difference: declared − used = unused
- Either prompts you to select which ones to remove, or removes all automatically
Installation
dotnet tool install -g nuget-cpm-cleaner
Usage
Interactive mode (default)
Displays a multi-select prompt listing all unused packages. Use space to toggle, enter to confirm.
nuget-cpm-cleaner --root C:/repos/my-solution
Auto-remove mode
Removes all unused packages without prompting.
nuget-cpm-cleaner --root . --auto-remove
Options
| Option | Description | Default |
|---|---|---|
--root |
Path to the repository root | Current directory |
--auto-remove |
Remove all unused packages without prompting | false |
Example Output
Found C:\repos\my-solution\Directory.Packages.props
Declared packages: 42
Referenced packages across .csproj files: 38
Found 4 unused package(s):
? Select packages to remove: (Press <space> to toggle, <enter> to confirm)
> [ ] Deprecated.Package
[ ] OldLibrary.Core
[ ] SomeUnused.Tool
[ ] UnusedAnalyzer
Done. Removed 2 package(s) from Directory.Packages.props:
- Deprecated.Package
- OldLibrary.Core
Requirements
- .NET 10 or later
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.