en

pcpm init

Initialise a PCPM workspace.

pcpm init is the entry point. It walks the current directory looking for a .sln or .csproj, then writes the three files PCPM expects to find in a workspace.

pcpm init [options]

What it does

  1. Locates the workspace root. If you’re in a subdirectory, PCPM walks up looking for a .sln or .csproj in an ancestor.
  2. If a pcpm.json already exists, leaves it alone (use --force to overwrite).
  3. If a Directory.Packages.props exists, adopts it. Otherwise, creates one with <ManagePackageVersionsCentrally>true</…/>.
  4. If --workspace is set, writes a pcpm-workspace.yaml that covers every project PCPM discovers.
  5. Runs pcpm install to produce the initial pcpm.lock.

Options

FlagEffect
--workspaceWrite a pcpm-workspace.yaml covering all projects.
--no-cpmDon’t create or touch Directory.Packages.props.
--no-installSkip the implicit pcpm install at the end.
--forceOverwrite an existing pcpm.json.
--name <name>Use <name> as the workspace name (default: directory name).

Examples

# In a project root with a single .csproj
pcpm init

# In a monorepo root
pcpm init --workspace

# Adopt an existing CPM layout, skip install
pcpm init --no-install

Files written

  • pcpm.json — always, unless it already exists.
  • Directory.Packages.props — only if CPM is not already enabled.
  • pcpm-workspace.yaml — only with --workspace.
  • pcpm.lock — only if --no-install is not set.

See also

  • pcpm convert — for projects that already have a solution file with PackageReference entries.
  • Quick start — a typical first run.