en

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

  1. Looks up <package> in Directory.Packages.props. If the package isn’t in CPM, prints an error and exits 1.
  2. Removes the <PackageVersion /> entry from Directory.Packages.props. If other packages in CPM don’t reference this version, the version is also dropped.
  3. Removes the <PackageReference Include="…" /> entry from every .csproj that has it.
  4. Runs pcpm install (skip with --no-install) to update pcpm.lock and refresh the store.

Options

FlagEffect
<package>The package id to remove.
--project <path>Remove from a specific .csproj only. Repeatable.
--all-projectsRemove from every project (default).
--keep-versionKeep the <PackageVersion /> entry even if no project uses it.
--no-installSkip 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>.

See also

  • pcpm add — inverse operation.
  • pcpm why — find out what’s pulling a package in.