Convert To Cpm
.NET (Microsoft)OfficialPublished by .NET (Microsoft)
- Skill
- Workflow
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured, safety-first workflow to migrate .NET solutions and projects to NuGet Central Package Management (CPM). It ensures version consistency across repositories by centralizing package declarations in a Directory.Packages.props file. The process includes a pre-conversion baseline capture, automated conflict resolution, and post-conversion validation using binlog comparison to ensure the migration is version-neutral and stable.
What it does
- Identifies and resolves package version conflicts across multiple projects.
- Creates or updates Directory.Packages.props to enable central package management.
- Captures baseline build and package resolution data for verification.
- Inlines MSBuild version properties into central package definitions.
- Validates the final state using binlog comparison and package list snapshots.
- Generates a structured report detailing changes, risks, and follow-up actions.
When to use it
- When you need to centralize and align NuGet package versions across a large .NET solution.
- When package versions are drifting or inconsistent between projects in a repository.
- When you want to adopt CPM but require evidence-based validation to ensure no breaking changes.
- When you need to resolve version mismatches while maintaining project-specific requirements.
Advantages
- Ensures version consistency, reducing dependency-related build errors.
- Provides a clear audit trail with before-and-after evidence.
- Minimizes manual effort through automated conflict detection and resolution.
- Preserves existing project metadata and build behavior.
- Includes a safety-first guard mode to prevent invalid migrations.
Usage examples
- “Convert my solution to use Central Package Management.”
- The agent will analyze the solution, capture the baseline, identify version conflicts, and generate the necessary Directory.Packages.props file while validating the result.
- “My NuGet packages are out of sync across my projects. Can you help?”
- The agent will audit the package versions, propose a resolution strategy for conflicts, and guide you through aligning them, potentially recommending a full CPM migration.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/dotnet/convert-to-cpm/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip convert-to-cpm.zip -d .agents/skills
Documentation by .NET (Microsoft)
Convert to Central Package Management
Centralize package versions in Directory.Packages.props while preserving project behavior and producing reviewable before/after evidence.
Choose a mode first
Do this before running builds or changing files.
Guard mode -- If any in-scope project uses
packages.config, stop. Explain that CPM requiresPackageReferenceand recommend migrating first. Do not create or modify files.Package-maintenance mode -- A request to update, align, bump, or sync packages authorizes those package edits, not CPM conversion. Audit the named scope, resolve the requested versions, update existing project/shared version declarations, and restore/build every affected CLI target from the directory that establishes its applicable
global.json. Ask only when the version or alignment policy is ambiguous. Do not create or modifyDirectory.Packages.props, remove versions for CPM, or capture conversion artifacts. Complete the package work, then recommend CPM as the durable follow-up.Conversion mode -- Use only when the user explicitly asks to adopt, enable, or convert to CPM. Follow the workflow below.
If the scope is unclear, ask once before proceeding.
Default execution plan
Guard: use a minimal scoped detection pass, then answer and stop.
Package maintenance: use a compact audit, edit only the requested package versions in their existing locations, validate affected targets, then recommend CPM. Do not read conversion references or enter the conversion workflow.
Conversion: batch the preflight, baseline, audit/mutation, final validation, and report work to avoid redundant turns. Revisit a stage only when new CPM-specific evidence requires a targeted follow-up.
This plan is an efficiency default, not a hard cap. Never omit an in-scope project, imported .props/.targets file, detected complexity, required validation, or deliverable to save a turn. Batch complete work where practical.
Inputs
| Input | Required | Rule |
|---|---|---|
| Scope | Yes | Project, solution, or directory containing the projects to inspect or convert |
| Conflict strategy | For package maintenance or conversion with conflicts | If the user already supplied a strategy such as "use the highest version," apply it without asking again and record its impact. Otherwise stop after the audit and ask before editing. |
Read references only when needed
Never preload all references.
| Condition | Read |
|---|---|
| Entering conversion baseline or producing the package diff | baseline-comparison.md |
A conflict, conditional reference, shared import, security concern, or VersionOverride is detected | audit-complexities.md |
Placement is unclear or conditional PackageVersion/VersionOverride is required | directory-packages-props.md |
| A package version uses an MSBuild property | msbuild-property-handling.md |
| Restore or build fails after conversion | validation-and-errors.md |
| Writing the final report | report-template.md |
Conversion workflow
1. Scope and preflight
Resolve the project/solution scope. For a solution, list its projects. For a directory, search only beneath that directory and create an explicit target set that covers the full scope: use each applicable
.sln/.slnx, then add each project not covered by a solution. Verify that every in-scope project is covered and avoid duplicate work for projects that occur in more than one target. Ask only when overlapping targets or repository boundaries make the intended coverage ambiguous; never ask the user to select one target when that would omit in-scope projects.Determine CPM management scopes separately from CLI targets. Group projects that will share one central version policy and place one
Directory.Packages.propsat each group's first common ancestor, while respecting existing nearest-file boundaries. Multiple CLI targets can share one CPM file; independent project groups can require separate files.Check for
packages.config; if found, switch to Guard mode and stop.Check the scope and ancestors for
Directory.Packages.props. If CPM is already fully enabled, report that and stop. If a partial file exists, preserve it and ask only when its intended scope is ambiguous.Choose one common artifact directory within the resolved scope, normally the targets' first common ancestor. Use explicit paths into it for every binlog, package snapshot, and the report.
Run each target's .NET commands from its solution/project directory or another directory that establishes its applicable
global.json, not from an unrelated parent workspace.Do not inspect unrelated projects or host-tool configuration when the user supplied a scope.
2. Capture the baseline
Read baseline-comparison.md. For each target, determine the active SDK once from that target's command directory and select the documented command syntax for that version. If SDK resolution fails or the SDK cannot process the requested solution format, stop and report the prerequisite; do not alter the host SDK or repository SDK policy unless the user asks.
Then use one command batch to:
Clean, restore, and build every explicit target. Use
baseline.binlogfor one target or a uniquebaseline-<target-key>.binlogfor each of multiple targets.Write resolved packages for every target without restoring again. Use
baseline-packages.jsonfor one target or a matchingbaseline-packages-<target-key>.jsonfor each of multiple targets.Keep normal command output concise. Save full output to artifacts when useful; inspect only errors on failure and never read the binlog as text.
Finish every baseline before editing. If any baseline build fails, stop without modifying files and preserve all artifacts already produced.
3. Audit with a targeted checklist
Use all baseline snapshots plus one targeted scan of in-scope project, .props, and .targets files. Identify:
Package IDs, resolved versions, and consuming projects
Version conflicts
MSBuild property-based versions and their definitions
Conditional
PackageReferenceitemsImported files containing package references
Existing
VersionOverrideusage
For a complex scope, complete every applicable item above across all projects and imported files; do not stop after finding the first conflict.
Do not run broad --outdated or --deprecated scans by default. Before editing, attempt a scoped --vulnerable --include-transitive query when the user requested security information, a known advisory must be verified, or conflict resolution will move a project across a major package version. Record the compact findings, "no advisories found," or why the check could not run. If a high-risk check is unavailable because of authentication, package-source, or offline constraints, surface the uncertainty and confirm the user's strategy rather than silently treating it as safe. Do not upgrade beyond the highest version already in scope as part of a CPM conversion.
Present conflicts and their impact. Explicitly classify major-version alignment as high risk and minor/patch alignment as moderate risk without performing an extra online scan. If the user supplied a conflict strategy, proceed. Otherwise ask for the unresolved decisions and stop before editing.
4. Create CPM files and update references
Create or update each required
Directory.Packages.propsat its computed management scope withManagePackageVersionsCentrallyset totrue.Add one alphabetically sorted
PackageVersionper package, preserving required target-framework conditions.Remove only
Versionfrom managedPackageReferenceitems in projects and imported files.Preserve conditions, whitespace, and all other metadata such as
PrivateAssets,IncludeAssets,ExcludeAssets,GeneratePathProperty, andAliases.Use
VersionOverrideonly when the chosen strategy requires it.
For MSBuild version properties, follow msbuild-property-handling.md. When the user directs inlining, include both the literal PackageVersion and removal of the obsolete property definition in the same mutation batch. Before final validation, verify separately that:
No
$(PropertyName)references remain in scoped project,.props, or.targetsfiles.No
<PropertyName>...</PropertyName>definition remains for each property chosen for removal.
Do not rely on a $() reference scan to prove that the XML property definition was removed.
5. Validate and compare
Using baseline-comparison.md, validate the final on-disk state after all project, shared-file, and property edits. Use one command batch to:
Clean, restore, and build every explicit target after all CPM edits. Use
after-cpm.binlogfor one target or a matchingafter-cpm-<target-key>.binlogfor each of multiple targets.Write resolved packages for every target without restoring again. Use
after-cpm-packages.jsonfor one target or a matchingafter-cpm-packages-<target-key>.jsonfor each of multiple targets.Produce a compact per-project changes/unchanged comparison without printing or rereading the full JSON files.
If resolved versions changed and the repository exposes a routine, scoped test command for affected projects, run it with
--no-build --no-restoreand record the result. If tests require substantial setup, broad infrastructure, or user approval, recommend the exact scoped command instead. A version-neutral conversion does not require an automatic test run.
If restore or build fails with a CPM-related error, read validation-and-errors.md, inspect only the relevant error lines, make a targeted correction, and rerun the affected validation. For SDK, authentication, package-source, file-lock, test-host, or other environmental failures, report the blocker instead of changing the machine or expanding the investigation.
If a test run fails after a successful build, inspect only enough output to determine whether CPM package resolution caused it. Apply a targeted correction only when the evidence clearly identifies a CPM defect; otherwise record the failure and recommended user action without expanding into test-host, SDK, output-directory, or dependency-copy debugging.
6. Write the report
Read report-template.md now, not earlier. Create convert-to-cpm.md beside the other artifacts. It must include the six required sections, every explicit target and CPM management scope, concrete conflict impacts, the aggregate package comparison, risk level, follow-ups, artifact usage, and the name of every shared .props/.targets file inspected or changed. In the final response, mention those shared files, the risk level, and how any conditional references and target frameworks were preserved. Avoid rewriting the report after validation unless verification finds an omission or incorrect evidence.
Required conversion artifacts
Preserve the report and every target's four evidence files; they are not temporary files. For one target, the five deliverables are:
baseline.binlogafter-cpm.binlogbaseline-packages.jsonafter-cpm-packages.jsonconvert-to-cpm.md
For multiple targets, replace the four fixed evidence names with unique target-keyed pairs such as baseline-api.binlog, after-cpm-api.binlog, baseline-packages-api.json, and after-cpm-packages-api.json. Keep one aggregate convert-to-cpm.md.
Efficiency rules
Batch independent reads and edits when supported.
Keep full build logs and package JSON out of the conversation; return compact summaries and artifact paths.
Do not repeat successful commands or reread successful output.
In conversion mode, do not perform package upgrades, broad outdated/deprecated scans, repeated tests, or unrelated repository exploration. The single conditional vulnerability query and test run defined above are part of complete high-risk conversion validation. Package maintenance can perform the requested upgrades and one scoped version-discovery query needed to resolve them.
Do not install or remove an SDK, create a temporary SDK selector, change roll-forward policy, invoke SDK-internal assemblies, kill unrelated processes, or clean host tooling/temp infrastructure. Report an environment prerequisite and stop.
Validation
[ ] Baseline and converted builds succeeded for every explicit target and all target binlogs exist
[ ] Every managed
PackageReferencehas noVersion, or intentionally usesVersionOverride[ ] Every managed package has the correct central
PackageVersion[ ] Conditions and non-version metadata were preserved
[ ] Before/after package comparison contains no unexplained changes
[ ] Inlined version properties have neither remaining
$()references nor obsolete XML definitions[ ] The report and all per-target baseline and converted artifacts exist
Files
- ATTRIBUTION.mdAdded by AutoGineer840 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md13.9 KiB
- references/audit-complexities.md5.3 KiB
- references/baseline-comparison.md7.2 KiB
- references/directory-packages-props.md3.6 KiB
- references/msbuild-property-handling.md3.5 KiB
- references/report-template.md3.6 KiB
- references/validation-and-errors.md3.2 KiB
references/directory-packages-props.md
Directory.Packages.props Creation
Placement
Repository scope: First group projects by the central version policy they must share. If all in-scope projects share one policy, place one file at their first common ancestor. If independent solutions or existing nearest-file boundaries require separate policies, place one file at each group's first common ancestor. This may produce one or more files, and none must be at the repository root.
Solution scope: Place at the first common ancestor of all governed projects, while respecting existing nearest-file boundaries. This is the solution directory only when it is an ancestor of every governed project.
Single project scope: Default to the project directory. If the project is inside a repository with other projects that may be converted later, ask the user where to place it.
Only the nearest Directory.Packages.props is evaluated per project. CPM also supports Directory.Packages.props in sub-folders — for example, test projects may have different dependencies than source code and can use a separate Directory.Packages.props in their sub-folder. A Directory.Packages.props in a sub-folder does not implicitly override or extend a parent file; it is independent and replaces the parent for projects in that folder. To share settings, explicitly chain files using MSBuild <Import> elements. See Central Package Management rules for how NuGet resolves which file applies. When in doubt about placement, ask the user.
CLI targets and CPM management scopes are different concepts. Multiple solution or project targets can use one common Directory.Packages.props, while one repository conversion can require separate files for independent project groups. Compute placement from the projects that share policy, not from the number or location of solution files.
Creating the file
Create the file directly so the workflow does not depend on whether the installed SDK includes the packagesprops template:
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- PackageVersion items will be added here -->
</ItemGroup>
</Project>Adding PackageVersion entries
Add a <PackageVersion> entry for each unique package, using the resolved version from the audit. Sort entries alphabetically by package ID:
<PackageVersion Include="PackageA" Version="1.2.3" />
<PackageVersion Include="PackageB" Version="4.5.6" />Conditional versions
If the same package needs different versions for different target frameworks, use MSBuild conditions:
<PackageVersion Include="PackageA" Version="1.0.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageVersion Include="PackageA" Version="2.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />Preserve an existing target-framework-specific version split when a single version is incompatible. Ask only when multiple valid policies remain and the user has not already supplied a strategy. Record the preserved condition in the report.
VersionOverride
If a project intentionally needs a different version than the centrally defined one, use VersionOverride in the project file instead of removing the Version attribute:
<PackageReference Include="System.Text.Json" VersionOverride="9.0.0" />Apply VersionOverride only when the user's chosen strategy requires it. If no strategy was supplied, ask before applying it; in most cases, version alignment is preferred.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- .NET (Microsoft)
- Publisher
- .NET (Microsoft) (Official)
- Source
- dotnet/skills · plugins/dotnet-nuget/skills/convert-to-cpm · commit 96c3d68
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by .NET (Microsoft) or .NET (Microsoft).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download convert-to-cpm.zip