pkg-trim
1.0.2
dotnet tool install --global pkg-trim --version 1.0.2
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local pkg-trim --version 1.0.2
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=pkg-trim&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package pkg-trim --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
pkg-trim
pkg-trim is a simple .NET CLI tool that analyzes your solution and identifies unused <PackageVersion> entries in your Directory.Packages.props file. Optionally, it can clean them up for you automatically.
Features
- Scans all
.csprojandDirectory.Build.propsfiles for usedPackageReferences - Compares them against the declared
PackageVersions inDirectory.Packages.props - Identifies unused package versions
- Supports an optional
--fixflag to automatically remove unused packages
Installation
dotnet tool install --global pkg-trim
Usage
pkg-trim [--sln-dir <path>] [--fix]
Options
--sln-diror--solution-directory
Path to the root directory of your solution (whereDirectory.Packages.propsis located).
If omitted, the tool will use the directory of the executable as default.--fix
If specified, removes the unused packages fromDirectory.Packages.props.
Without this flag, the tool only lists the unused entries.
Example
pkg-trim --sln-dir /path/to/solution
pkg-trim --fix
How It Works
- Scans all
.csprojandDirectory.Build.propsfiles recursively in the provided solution directory. - Collects all used
PackageReferencenames. - Loads the
Directory.Packages.propsfile and checks for<PackageVersion>entries that are no longer used. - Lists them in the output, and removes them if
--fixis passed.
Why
Over time, projects accumulate package versions that are no longer used. Keeping your Directory.Packages.props file clean helps:
- Reduce confusion and clutter
- Improve maintainability of your solution
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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.