Automate the adoption of Central Package Management (CPM) in your solutions. This extension 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
- FAQ
- Prerequisites
- Support & Feedback
- Coming Soon
📜 Version History (Major releases)
v1.1.6
- Added support for projects that target multiple .Net frameworks using the
<TargetFrameworks>
attribute.
- Bugfixes
v1.1.0
v1.0.0
- First version with CPM features.
💡 FAQ
➡️ What does this extension 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 run this extension.
Open a Solution
Open any .NET solution in Visual Studio and wait for it to finish loading all projects.
Run the Extension
Navigate to Tools > Centralize NuGet Package Versions
.
This will cause the extension to:
- Analyze projects.
- Create a
Directory.Packages.props
file at solution level folder, and add it to the solution.
- Modify
.csproj
files.
Review
Monitor the 'Centralize Package Versions' output panel for updates, it will display success or warning messages. Critical errors that require actionable error feedback will be displayed via a Message box.
➡️ 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>
📌 Prerequisites
In order for this extension to work properly, the following CPM pre-requisites need to be met:
- Visual Studio 2022 17.2 or above.
- All projects should be targeting at least .Net 6.0.
- Nuget.exe v6.2.0 should be installed.
✒️ Support & Feedback
If this extension has made your life easy, please give it a ★★★★★ rating on the Visual Studio Marketplace. It would also help me immensely if you could leave a review in the Rating & Review section.
Should you encounter bugs or if you have feature requests, please drop me a note at at cvm@vishal.mozmail.com.
🔭 Coming Soon
- Visual Studio 17.14 support
.NET
target framework centralization
- Summary reports of centralized dependencies