Agent skill
dotnet-centralise-packages
Converts a .NET solution to use Central Package Management (CPM). Also use when the user mentions "centralize packages," "CPM," "Directory.Packages.props," "unify package versions," "consolidate NuGet," or "central package management." For updating package versions, see dotnet-update-packages.
Install this agent skill to your Project
npx add-skill https://github.com/Im5tu/claude/tree/main/skills/dotnet-centralise-packages
Metadata
Additional technical details for this skill
- author
- Im5tu
- version
- 1.0
- repositoryUrl
- https://github.com/im5tu/dotnet-skills
SKILL.md
Convert the current .NET solution to use Central Package Management, centralizing all package versions in a single Directory.Packages.props file.
Steps
-
Find the solution file (*.sln) in the current directory
- If no .sln found, warn and stop
-
List all packages (including transitive)
bashdotnet package list --include-transitive --format json -
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
-
Check for existing CPM files
- If
Directory.Packages.propsexists, ask user: overwrite or merge - Note existing
Directory.Build.propscontent if present
- If
-
Create
Directory.Packages.propsnext to the .sln file:xml<Project> <ItemGroup> <PackageVersion Include="PackageName" Version="X.Y.Z" /> <!-- one entry per unique package --> </ItemGroup> </Project> -
Create or update
Directory.Build.propsnext to the .sln file:- If file exists, add the property to existing content
- If file doesn't exist, create it:
xml<Project> <PropertyGroup> <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> </PropertyGroup> </Project> -
Update all .csproj files:
- Remove
Versionattribute from all<PackageReference>elements - Before:
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> - After:
<PackageReference Include="Newtonsoft.Json" />
- Remove
-
Run build to verify:
bashdotnet build -
If build fails, ask the user:
- Fix automatically: Review errors and attempt fixes
- Fix manually: Show errors and let user handle
-
Report results:
- List all created/modified files
- Show package count centralized
- Confirm build status
Transitive vs Direct Packages
- Direct packages: Explicitly in csproj via
<PackageReference>. 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.propsby default - Report transitive packages separately for awareness
- If user wants to pin a transitive, add it as a
<PackageVersion>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.propsalready exists: ask to overwrite or merge - If build fails after conversion: offer automatic fix or manual intervention
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
flutter-animations
Comprehensive guide for implementing animations in Flutter. Use when adding motion and visual effects to Flutter apps: implicit animations (AnimatedContainer, AnimatedOpacity, TweenAnimationBuilder), explicit animations (AnimationController, Tween, AnimatedWidget/AnimatedBuilder), hero animations (shared element transitions), staggered animations (sequential/overlapping), and physics-based animations. Includes workflow for choosing the right animation type, implementation patterns, and best practices for performance and user experience.
dotnet-source-gen-logging
Converts logging to use the LoggerMessage source generator for high-performance, AOT-compatible logging. Also use when the user mentions "LoggerMessage," "logging source generator," "high-performance logging," "optimize logging," "AOT logging," or "structured logging source gen." For full AOT analysis, see dotnet-aot-analysis.
dotnet-source-gen-options-validation
Converts options validation to use the compile-time source generator for AOT-compatible, reflection-free validation. Also use when the user mentions "OptionsValidator," "options validation source gen," "AOT options validation," "compile-time validation," "ValidateDataAnnotations replacement," or "reflection-free validation." For full AOT analysis, see dotnet-aot-analysis.
dotnet-enable-testing-platform
Enables the Microsoft Testing Platform runner in global.json. Also use when the user mentions "testing platform," "Microsoft.Testing.Platform," "new test runner," "migrate test runner," "global.json testing," or "modern test platform."
dotnet-json-polymorphic
Configures polymorphic JSON serialization with [JsonPolymorphic] and [JsonDerivedType] attributes. Also use when the user mentions "polymorphic JSON," "JsonDerivedType," "JSON inheritance," "type discriminator," "serialize derived types," or "JSON polymorphism." For full JSON source generation, see dotnet-source-gen-json.
competitor-alternatives
When the user wants to create competitor comparison or alternative pages for SEO and sales enablement. Also use when the user mentions 'alternative page,' 'vs page,' 'competitor comparison,' 'comparison page,' '[Product] vs [Product],' '[Product] alternative,' or 'competitive landing pages.' Covers four formats: singular alternative, plural alternatives, you vs competitor, and competitor vs competitor. Emphasizes deep research, modular content architecture, and varied section types beyond feature tables.
Didn't find tool you were looking for?