Skip to content

Migrate to Centralized NuGet Package Management (CPM)#82

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

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

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

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

Changes

  • Directory.Packages.props (new) — enables CPM with <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>; declares 17 <PackageVersion> entries sorted alphabetically
  • PolyShim/PolyShim.csproj — stripped Version="..." from all <PackageReference> elements; all PrivateAssets and Condition attributes preserved
  • PolyShim.Tests/PolyShim.Tests.csproj — same; all PrivateAssets attributes preserved
  • PolyShim.sln — added Directory.Packages.props to the Misc solution items folder

Before / After

<!-- Before (per-project) -->
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" PrivateAssets="all" Condition="..." />

<!-- After (centrally managed) -->
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" PrivateAssets="all" Condition="..." />

No version conflicts across projects — all shared packages already used consistent versions.

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. 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.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@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:41
Copilot AI review requested due to automatic review settings February 26, 2026 19:41
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 pull request successfully migrates the PolyShim repository to NuGet's Centralized Package Management (CPM) pattern, consolidating all package version definitions from individual project files into a single Directory.Packages.props file at the repository root. This provides a single source of truth for dependency versions across the solution.

Changes:

  • Created Directory.Packages.props with 17 centrally-managed package versions
  • Removed Version attributes from all <PackageReference> elements in both project files while preserving all other attributes
  • 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 2 comments.

File Description
Directory.Packages.props New file enabling CPM with 17 PackageVersion entries for all dependencies
PolyShim/PolyShim.csproj Removed Version attributes from 19 PackageReference elements; preserved all PrivateAssets and Condition attributes
PolyShim.Tests/PolyShim.Tests.csproj Removed Version attributes from 10 PackageReference elements; preserved all PrivateAssets attributes
PolyShim.sln Added Directory.Packages.props to Misc solution items folder

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

Tyrrrz and others added 2 commits February 26, 2026 21:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz Tyrrrz merged commit 0c7f42a into master Feb 26, 2026
5 checks passed
@Tyrrrz Tyrrrz deleted the copilot/migrate-to-centralized-package-management branch February 26, 2026 19:50
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