Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Centralize Versions
Centralize Versions

Centralize Versions

Vishal Trivedi

|
15 installs
| (1) | Free
Automates Central Package Management in .NET solutions by unifying NuGet version declarations, ensuring consistency, and reducing versioning errors across all projects.
Download

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

  1. Version History
  2. FAQ
  3. Prerequisites
  4. Support & Feedback
  5. 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

  • SLNX support: The new and improved SLNX Solution Format is now supported. Tested using Visual Studio 2022 v17.14 - Preview 3.

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.

  1. Open a Solution
    Open any .NET solution in Visual Studio and wait for it to finish loading all projects.

  2. 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.
  3. 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:

    1. All discovered versions are parsed using NuGetVersion.TryParse.
    2. Versions that can't be parsed (e.g. typos or invalid strings) are skipped and logged.
    3. Pre-release versions (e.g. -beta, -rc, -alpha) are ignored unless no stable versions are found.
    4. The latest valid stable version is chosen as the default.
    5. 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

      Versions found:

      • Newtonsoft.Json
        • 13.0.1-beta
        • 13.0.1 ✅ (stable)
        • 12.0.3

      Result:
      ✔️ 13.0.1 is selected — it's the latest stable version.

    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

      Versions found:

      • MyCompany.Custom.Package
        • 1.0.0
        • abc ❌ (invalid)
        • 1.1.0

      Result:
      ✔️ 1.1.0 is selected — the invalid version is skipped with a warning.

➡️ What’s Considered a Pre-release?

    Any version with a suffix (after a -) is considered a pre-release:

    Version Pre-release? Notes
    1.0.0 ❌ No Stable
    1.0.0-alpha ✅ Yes Pre-release
    2.0.0-preview.3 ✅ Yes Pre-release
    3.1.0-rc.1+build123 ✅ Yes Pre-release (metadata ignored)

➡️ 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
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft