Skip to content

Migrate to Centralized NuGet Package Management (CPM)#21

Merged
Tyrrrz merged 3 commits intomasterfrom
copilot/migrate-to-centralized-package-management
Feb 26, 2026
Merged

Migrate to Centralized NuGet Package Management (CPM)#21
Tyrrrz merged 3 commits intomasterfrom
copilot/migrate-to-centralized-package-management

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

Consolidates all NuGet package versions into a single Directory.Packages.props file using NuGet CPM, eliminating per-project Version attributes.

Changes

  • Directory.Packages.props (new) — root-level file with ManagePackageVersionsCentrally=true and alphabetically sorted <PackageVersion> entries for all 12 packages
  • JsonExtensions.csproj / JsonExtensions.Tests.csprojVersion="..." removed from all <PackageReference> elements; all other attributes (PrivateAssets, Condition) preserved unchanged
  • JsonExtensions.slnDirectory.Packages.props added as a solution item under the existing Misc folder

Before:

<PackageReference Include="System.Text.Json" Version="10.0.2"
  Condition="!$([MSBuild]::IsTargetFrameworkCompatible(...))" />

After (version now in Directory.Packages.props):

<PackageReference Include="System.Text.Json"
  Condition="!$([MSBuild]::IsTargetFrameworkCompatible(...))" />

No version conflicts across projects — CSharpier.MsBuild appears in both at 1.2.1.

Original prompt

Migrate to Centralized NuGet Package Management (CPM)

Migrate the repository from per-project Version attributes on <PackageReference> to NuGet's Centralized Package Management (CPM).

What to do

  1. Create a Directory.Packages.props file at the root of the repository with <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> and a <PackageVersion> entry for every unique package used across all .csproj files. Use the version already present in the .csproj files.

  2. Update all .csproj files to remove the Version="..." attribute from every <PackageReference> element (CPM now manages the version centrally). Keep all other attributes (e.g. PrivateAssets, Condition, ExcludeAssets, etc.) intact.

  3. Add Directory.Packages.props to the .sln file as a solution item, typically under a Solution Items folder, so it is visible and accessible from within the solution.

  4. Run dotnet build at the end to catch and fix any formatting or structural issues introduced during the migration.

  5. Do not change any TargetFramework(s), project structure, or anything unrelated to package versioning.

Reference

See how it was done in the sibling repo Tyrrrz/YoutubeExplode PR #940: Tyrrrz/YoutubeExplode#940

Notes

  • If a package appears with different versions in different projects, use the highest version and make a note in the PR description.
  • <PackageVersion> entries in Directory.Packages.props should be sorted alphabetically.
  • Make sure the file includes a valid MSBuild props file <Project> root element.
  • Preserve all Condition attributes on <PackageReference> elements.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Tyrrrz Tyrrrz added the enhancement New feature or request label Feb 26, 2026
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate repository to centralized NuGet package management Migrate to Centralized NuGet Package Management (CPM) Feb 26, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review February 26, 2026 19:55
Copilot AI review requested due to automatic review settings February 26, 2026 19:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the JsonExtensions repository from per-project package version management to Centralized NuGet Package Management (CPM), following the NuGet CPM pattern. The migration consolidates all 12 package versions into a root-level Directory.Packages.props file, removing version attributes from individual project files while preserving all other package reference attributes.

Changes:

  • Created Directory.Packages.props with centralized version management for all 12 NuGet packages
  • Removed Version attributes from all <PackageReference> elements in both project files
  • Added Directory.Packages.props to the solution's Misc folder for visibility

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Directory.Packages.props New file defining centralized package versions with ManagePackageVersionsCentrally enabled
JsonExtensions/JsonExtensions.csproj Removed version attributes from 6 package references while preserving PrivateAssets and Condition attributes
JsonExtensions.Tests/JsonExtensions.Tests.csproj Removed version attributes from 7 test-related package references while preserving PrivateAssets attributes
JsonExtensions.sln Added Directory.Packages.props to the Misc solution folder for IDE visibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz Tyrrrz merged commit 6a7459d into master Feb 26, 2026
5 checks passed
@Tyrrrz Tyrrrz deleted the copilot/migrate-to-centralized-package-management branch February 26, 2026 20:03
@codecov
Copy link

codecov bot commented Feb 26, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants