Skip to content

Migrate to Centralized NuGet Package Management (CPM)#57

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

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

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

  • Create Directory.Packages.props with all package versions (alphabetically sorted)
  • Update all .csproj files to remove Version="..." from <PackageReference> elements
  • Add Directory.Packages.props to the .sln file under the existing "Misc" solution items folder
  • Fix formatting in Directory.Packages.props to match Directory.Build.props style (blank lines after <Project> and before </Project>)
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.


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

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 added the enhancement New feature or request label Feb 26, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review February 26, 2026 19:32
Copilot AI review requested due to automatic review settings February 26, 2026 19:32
@Tyrrrz
Copy link
Owner

Tyrrrz commented Feb 26, 2026

@copilot formatting issues

Copy link

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 repository from per-project NuGet package version management to Centralized Package Management (CPM), consolidating all package versions into a single Directory.Packages.props file at the repository root. This follows Microsoft's recommended approach for managing package versions across multi-project solutions and improves maintainability by eliminating version duplication.

Changes:

  • Created Directory.Packages.props with centralized version definitions for 7 NuGet packages
  • Removed Version attributes from <PackageReference> elements in all 6 project files while preserving other attributes
  • Added Directory.Packages.props to the solution's "Misc" folder for visibility

Reviewed changes

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

Show a summary per file
File Description
Directory.Packages.props New file enabling CPM with alphabetically sorted PackageVersion entries for all 7 packages
DotnetRuntimeBootstrapper/DotnetRuntimeBootstrapper.csproj Removed Version attributes from 6 PackageReference elements, preserved all other attributes
DotnetRuntimeBootstrapper.sln Added Directory.Packages.props to the Misc solution folder
DotnetRuntimeBootstrapper.Demo.Gui/DotnetRuntimeBootstrapper.Demo.Gui.csproj Removed Version attribute from CSharpier.MsBuild PackageReference
DotnetRuntimeBootstrapper.Demo.Cli/DotnetRuntimeBootstrapper.Demo.Cli.csproj Removed Version attribute from CSharpier.MsBuild PackageReference
DotnetRuntimeBootstrapper.AppHost.Gui/DotnetRuntimeBootstrapper.AppHost.Gui.csproj Removed Version attributes from 3 PackageReference elements
DotnetRuntimeBootstrapper.AppHost.Core/DotnetRuntimeBootstrapper.AppHost.Core.csproj Removed Version attributes from 3 PackageReference elements
DotnetRuntimeBootstrapper.AppHost.Cli/DotnetRuntimeBootstrapper.AppHost.Cli.csproj Removed Version attributes from 3 PackageReference elements

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

…rops style

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot formatting issues

Fixed in 8303faa — added blank lines after <Project> and before </Project> in Directory.Packages.props to match the style of Directory.Build.props.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Feb 26, 2026

@copilot run dotnet build and commit the changes

Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot run dotnet build and commit the changes

Build passes — all non-Windows projects restore and compile successfully with the CPM changes. The only failure is the pre-existing NETSDK1100 on Demo.Gui (WinForms project that requires Windows to build) which also fails on the base branch before our changes. No code changes are needed.

@Tyrrrz Tyrrrz merged commit 2e305a4 into master Feb 26, 2026
5 checks passed
@Tyrrrz Tyrrrz deleted the copilot/migrate-to-centralized-nuget-management branch February 26, 2026 19:46
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