pcpm remove
Remove a direct dependency.
pcpm remove is the inverse of pcpm add. It
removes a direct dependency from CPM and from every .csproj
that references it.
pcpm remove <package> [options]
What it does
- Looks up
<package>inDirectory.Packages.props. If the package isn’t in CPM, prints an error and exits 1. - Removes the
<PackageVersion />entry fromDirectory.Packages.props. If other packages in CPM don’t reference this version, the version is also dropped. - Removes the
<PackageReference Include="…" />entry from every.csprojthat has it. - Runs
pcpm install(skip with--no-install) to updatepcpm.lockand refresh the store.
Options
| Flag | Effect |
|---|---|
<package> | The package id to remove. |
--project <path> | Remove from a specific .csproj only. Repeatable. |
--all-projects | Remove from every project (default). |
--keep-version | Keep the <PackageVersion /> entry even if no project uses it. |
--no-install | Skip the implicit pcpm install. |
Examples
# Remove Serilog from every project
pcpm remove Serilog
# Remove from a single project
pcpm remove Serilog --project src/Api/Api.csproj
# Remove without updating the lockfile
pcpm remove Serilog --no-install
Transitive dependencies
pcpm remove only removes direct dependencies. If a package
is brought in transitively (e.g. Microsoft.Extensions.Logging
is required by Microsoft.Extensions.Hosting), pcpm remove
won’t help — the transitive package will stay in the lockfile
until the parent is also removed.
To see who is bringing a transitive package in, use
pcpm why <pkg>.