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
.csproj
andDirectory.Build.props
files for usedPackageReference
s - Compares them against the declared
PackageVersion
s inDirectory.Packages.props
- Identifies unused package versions
- Supports an optional
--fix
flag to automatically remove unused packages
Installation
dotnet tool install --global pkg-trim
Usage
pkg-trim [--sln-dir <path>] [--fix]
Options
--sln-dir
or--solution-directory
Path to the root directory of your solution (whereDirectory.Packages.props
is 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
.csproj
andDirectory.Build.props
files recursively in the provided solution directory. - Collects all used
PackageReference
names. - Loads the
Directory.Packages.props
file and checks for<PackageVersion>
entries that are no longer used. - Lists them in the output, and removes them if
--fix
is 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.