Automate the adoption of Central Package Management (CPM) in your solutions. This tool centralizes NuGet package version declarations across all projects in a solution. This helps enforce consistency, reduce versioning errors across large codebases, and of course save time.
📋 Table of Contents
- Version History
- What does it do
- How to use it
- FAQ
- Current Limitations
- Pre-requisites
- Support & Feedback
- Coming Soon
📜 Version History (Major releases)
v1.1.0
v1.0.0
- First version with CPM features.
▶️ What does it do
- Automates Central Package Management: Scans your solution and moves all NuGet package version declarations into a centralized
Directory.Packages.props
file.
- Cleans Up Individual Projects: Updates project files (e.g.,
.csproj
) to remove inline version numbers, aligning them with centralized management.
- Transactional Workflow: All operations are performed in a transaction-like fashion — if any step fails, all changes are rolled back to maintain project stability.
- Minimal User Interaction Required
Designed for simplicity — just open your solution, click a menu option, and the extension does the rest.
▶️ How to use It
Open a Solution
Open any .NET solution in Visual Studio and wait for it to finish loading all projects.
Launch the Tool
Navigate to Tools > Centralize NuGet Package Versions
.
Review & Apply
The extension will automatically:
- Analyze projects.
- Create a
Directory.Packages.props
file at solution level folder, and add it to the solution.
- Modify
.csproj
files.
Done!
Monitor the 'Centralize Package Versions' panel for updates. It will display success or warning messages. Critical errors that require actionable error feedback will be displayed via a Message box.
💡 FAQ
➡️ How is a NuGet Version selected if there are multiple versions of the same NuGet package referenced by different projects?
When scanning .csproj
files, the extension may find multiple versions of the same NuGet package across different projects in your solution. To help centralize dependency management, the extension automatically selects a default version for each package. This version is typically the latest stable release.
Version Selection Logic
The extension uses the official NuGet.Versioning
library to parse and compare versions, following SemVer 2.0.0. The logic works as follows:
- All discovered versions are parsed using
NuGetVersion.TryParse
.
- Versions that can't be parsed (e.g. typos or invalid strings) are skipped and logged.
- Pre-release versions (e.g.
-beta
, -rc
, -alpha
) are ignored unless no stable versions are found.
- The latest valid stable version is chosen as the default.
- If no stable versions exist, the latest pre-release is used as fallback.
Examples with Real NuGet Packages
Example 1: Stable and Pre-release Versions
Example 2: Only Pre-release Versions
Versions found:
Microsoft.Extensions.Logging
6.0.0-preview.3
6.0.0-rc.2
Result:
✔️ 6.0.0-rc.2
is selected — the latest pre-release is used because no stable version is found.
Example 3: Includes Invalid Version Strings
➡️ What’s Considered a Pre-release?
➡️ Can I Override the Default Version?
Yes! You can override an individual package version by using the VersionOverride property on a <PackageReference />
item. This overrides any <PackageVersion />
defined centrally. Example:
Directory.Packages.props
<Project>
<ItemGroup>
<PackageVersion Include="PackageA" Version="1.0.0" />
<PackageVersion Include="PackageB" Version="2.0.0" />
</ItemGroup>
</Project>
MyConsoleApp.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PackageA" VersionOverride="3.0.0" />
</ItemGroup>
</Project>
⚠️ Current Limitations
Only Supports SDK-Style Projects
Older project formats are not supported.
Experimental .NET Version Centralization
Automatically updating target framework versions is optional and should be used with caution in multi-targeted solutions.
📌 Pre-requisites
- Visual Studio 2022 17.2 (Although, my tests with VS v17.13.5 onwards have run successfully.)
- All projects should be targeting at least .Net 6.0
- Nuget.exe v6.2.0 should be installed.
✒️ Support & Feedback
Please share your questions/suggestions/bug reports at cvm@vishaltrivedi.anonaddy.me or in the Q & A section of this extension. It would help me immensely if you could leave a review in the Rating & Review section.
🔭 Coming Soon
- Visual Studio 17.14 support
.NET
target framework centralization
- Summary reports of centralized dependencies