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
- Locates the workspace root. If you’re in a subdirectory, PCPM
walks up looking for a
.slnor.csprojin an ancestor. - If a
pcpm.jsonalready exists, leaves it alone (use--forceto overwrite). - If a
Directory.Packages.propsexists, adopts it. Otherwise, creates one with<ManagePackageVersionsCentrally>true</…/>. - If
--workspaceis set, writes apcpm-workspace.yamlthat covers every project PCPM discovers. - Runs
pcpm installto produce the initialpcpm.lock.
Options
| Flag | Effect |
|---|---|
--workspace | Write a pcpm-workspace.yaml covering all projects. |
--no-cpm | Don’t create or touch Directory.Packages.props. |
--no-install | Skip the implicit pcpm install at the end. |
--force | Overwrite 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-installis not set.
See also
pcpm convert— for projects that already have a solution file withPackageReferenceentries.- Quick start — a typical first run.