Skip to content

Migrate to Centralized NuGet Package Management (CPM)#21

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

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

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 26, 2026

Moves package version management from per-project Version="..." attributes to NuGet's Centralized Package Management, establishing a single source of truth for all dependency versions.

Changes

  • Directory.Packages.props (new) — enables CPM with ManagePackageVersionsCentrally=true; declares all 7 packages alphabetically:
    <PackageVersion Include="CSharpier.MsBuild" Version="1.1.2" />
    <PackageVersion Include="coverlet.collector" Version="6.0.4" />
    <PackageVersion Include="FluentAssertions" Version="8.8.0" />
    <PackageVersion Include="GitHubActionsTestLogger" Version="3.0.1" />
    <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
    <PackageVersion Include="xunit" Version="2.9.3" />
    <PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
  • QuickJson.csproj / QuickJson.Tests.csprojVersion attributes stripped from all <PackageReference> elements; all other attributes (PrivateAssets, etc.) preserved
  • QuickJson.slnDirectory.Packages.props added as a solution item under the existing Misc folder

No version conflicts — CSharpier.MsBuild appears in both projects at the same version (1.1.2).

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.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@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 to Centralized NuGet Package Management Migrate to Centralized NuGet Package Management (CPM) Feb 26, 2026
Copilot AI requested a review from Tyrrrz February 26, 2026 19:56
@Tyrrrz Tyrrrz marked this pull request as ready for review February 26, 2026 20:03
Copilot AI review requested due to automatic review settings February 26, 2026 20:03
Copy link
Copy Markdown

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 pull request migrates the repository from per-project package version management to NuGet's Centralized Package Management (CPM) pattern, consolidating all package versions into a single Directory.Packages.props file. This establishes a single source of truth for dependency versions across the solution.

Changes:

  • Created Directory.Packages.props with centralized version management enabled and all 7 package versions defined alphabetically
  • Removed Version attributes from all PackageReference elements in both project files while preserving other attributes
  • Added Directory.Packages.props to the solution file under the existing Misc folder

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
Directory.Packages.props New file enabling CPM with ManagePackageVersionsCentrally=true and defining all 7 package versions alphabetically
QuickJson.csproj Removed Version attribute from CSharpier.MsBuild package reference while preserving PrivateAssets
QuickJson.Tests.csproj Removed Version attributes from all 7 package references while preserving PrivateAssets attributes
QuickJson.sln Added Directory.Packages.props as a solution item under the Misc folder

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

@Tyrrrz Tyrrrz merged commit 54e08ea into master Feb 26, 2026
11 checks passed
@Tyrrrz Tyrrrz deleted the copilot/migrate-to-centralized-nuget-management branch February 26, 2026 20:12
@codecov
Copy link
Copy Markdown

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