🎯

dotnet-centralise-packages

🎯Skill

from im5tu/dotnet-skills

VibeIndex|
What it does

Centralizes NuGet package versions across .NET projects by creating a single `Directory.Packages.props` file and updating project references.

πŸ“¦

Part of

im5tu/dotnet-skills(10 items)

dotnet-centralise-packages

Installation

Quick InstallInstall with npx
npx skills add im5tu/dotnet-skills
πŸ“– Extracted from docs: im5tu/dotnet-skills
1Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

Converts a .NET solution to use Central Package Management (CPM). Use when the user wants to centralize, consolidate, or unify NuGet package versions across projects.

Overview

Convert the current .NET solution to use Central Package Management, centralizing all package versions in a single Directory.Packages.props file.

Steps

  1. Find the solution file (*.sln) in the current directory

- If no .sln found, warn and stop

  1. List all packages (including transitive)

```bash

dotnet package list --include-transitive --format json

```

  1. Parse JSON output to extract:

- All unique packages across all projects

- Their versions

- Whether each package is direct or transitive

- If same package has different versions, use the highest version

  1. Check for existing CPM files

- If Directory.Packages.props exists, ask user: overwrite or merge

- Note existing Directory.Build.props content if present

  1. Create Directory.Packages.props next to the .sln file:

```xml

```

  1. Create or update Directory.Build.props next to the .sln file:

- If file exists, add the property to existing content

- If file doesn't exist, create it:

```xml

true

```

  1. Update all .csproj files:

- Remove Version attribute from all elements

- Before:

- After:

  1. Run build to verify:

```bash

dotnet build

```

  1. If build fails, ask the user:

- Fix automatically: Review errors and attempt fixes

- Fix manually: Show errors and let user handle

  1. Report results:

- List all created/modified files

- Show package count centralized

- Confirm build status

Transitive vs Direct Packages

  • Direct packages: Explicitly in csproj via . These get centralized.
  • Transitive packages: Pulled in as dependencies. Generally NOT centralized unless:

- User explicitly wants to pin a transitive package version

- A transitive package needs a security update

When centralizing:

  • Only add direct packages to Directory.Packages.props by default
  • Report transitive packages separately for awareness
  • If user wants to pin a transitive, add it as a entry

Version Conflict Resolution

When the same package has different versions across projects:

  • Automatically use the highest/latest version
  • No user prompt needed

Error Handling

  • If no .sln found: warn about solution-level CPM requirement
  • If Directory.Packages.props already exists: ask to overwrite or merge
  • If build fails after conversion: offer automatic fix or manual intervention

More from this repository9

🎯
dotnet-enable-testing-platform🎯Skill

Enables and configures testing platforms and frameworks for .NET projects, streamlining test setup and infrastructure.

🎯
dotnet-source-gen-logging🎯Skill

Transforms .NET logging calls to use LoggerMessage source generator for high-performance, AOT-compatible logging with zero boxing overhead.

🎯
dotnet-json-polymorphic🎯Skill

Converts JSON payloads with polymorphic type handling, enabling dynamic deserialization of complex .NET object hierarchies.

🎯
dotnet-source-gen-options-validation🎯Skill

Converts options validation to compile-time source generator for AOT-compatible, reflection-free validation at startup.

🎯
dotnet-source-gen-json🎯Skill

Generates JSON serialization and deserialization code for .NET classes using source generators, improving performance and reducing boilerplate.

🎯
dotnet-source-gen-regex🎯Skill

Converts .NET regex instances to compile-time source-generated implementations for improved performance and AOT compatibility.

🎯
dotnet-enable-autocomplete🎯Skill

Enables dotnet CLI tab autocomplete across multiple shells, automatically detecting .NET version and configuring shell-specific completion scripts.

🎯
dotnet-update-packages🎯Skill

Automatically lists and updates outdated NuGet packages in .NET projects, guiding users through dependency management with interactive confirmation.

🎯
dotnet-aot-analysis🎯Skill

Analyzes and configures .NET projects for Native AOT compatibility, applying source generators and optimizing AOT deployment settings.