en

pcpm convert

Migrate an existing solution into a PCPM workspace.

pcpm convert [options]

pcpm convert is a one-shot migration command. It takes an existing .NET solution (with or without Central Package Management) and turns it into a PCPM workspace.

What it does

  1. Walks the workspace, collecting every <PackageReference />.
  2. Adopts your existing Directory.Packages.props if you have one; otherwise creates one.
  3. Strips Version="…" from every <PackageReference /> and writes the version as a <PackageVersion /> in CPM.
  4. Writes pcpm.json.
  5. With --workspace, writes pcpm-workspace.yaml covering all projects.
  6. Runs pcpm install to materialise the store and write pcpm.lock.

Options

FlagEffect
--workspaceAlso write pcpm-workspace.yaml.
--no-installSkip the implicit pcpm install.
--no-cpmDon’t create or touch Directory.Packages.props.
--forceRe-run even if pcpm.json already exists.
--backupSnapshot every modified file to pcpm-convert.bak/ before editing.

Examples

# Standard migration
pcpm convert

# Monorepo migration
pcpm convert --workspace

# Migration that doesn't change the lockfile
pcpm convert --no-install

What it doesn’t change

pcpm convert is conservative. It does not:

  • Touch anything other than the files described above.
  • Update package versions. It normalises what you have.
  • Change your NuGet feed configuration.
  • Modify the build graph or properties.

Rolling back

pcpm convert is git-friendly. The full set of changes is visible in git status:

git status
# On branch main
# Changes to be committed:
#   new file:   pcpm.json
#   modified:   Directory.Packages.props
#   modified:   src/Api/Api.csproj
#   ...

To roll back:

git restore .

If you used --backup, the originals are in pcpm-convert.bak/ and can be restored manually.

See also