Skip to content

Migrate to Centralized NuGet Package Management (CPM)#1489

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

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

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 26, 2026

  • Explore all .csproj files and collect package references
  • Create Directory.Packages.props with all 34 package versions centrally managed (alphabetically sorted)
  • Update all .csproj files to remove Version="..." attributes from <PackageReference> elements
  • Add Directory.Packages.props to the Misc solution folder in DiscordChatExporter.sln
  • Fix Dockerfile to COPY Directory.Packages.props so the Docker build can restore packages via CPM
  • Fix CSharpier formatting: collapse multi-line <PackageReference> elements that became single-attribute after Version removal
  • Verify build and format check succeed
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. 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

Projects in this repo

Check the repository for all .csproj files (there are likely src and test projects).

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 xmlns or is a valid MSBuild props file: <Project> root element.

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.

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
@Tyrrrz Tyrrrz marked this pull request as ready for review February 26, 2026 19:01
Copilot AI review requested due to automatic review settings February 26, 2026 19:01
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Feb 26, 2026

@copilot add the created Directory.Packages.props file to the sln file

Also, the docker build fails. Perhaps it's using an old SDK or otherwise doesn't support CPM?

Copy link
Copy Markdown
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 repository from per-project NuGet package version management to Microsoft's Centralized Package Management (CPM) pattern, consolidating all 34 package versions into a single Directory.Packages.props file at the repository root.

Changes:

  • Created Directory.Packages.props with centralized version management for 34 packages
  • Removed Version attributes from all <PackageReference> elements across 4 .csproj files
  • Preserved all other package reference attributes (PrivateAssets, Condition, etc.)

Reviewed changes

Copilot reviewed 5 out of 5 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 34 alphabetically sorted PackageVersion entries
DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj Removed Version attributes from 15 package references while preserving PrivateAssets and Condition attributes
DiscordChatExporter.Core/DiscordChatExporter.Core.csproj Removed Version attributes from 10 package references while preserving PrivateAssets attributes
DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj Removed Version attributes from 5 package references while preserving PrivateAssets attributes
DiscordChatExporter.Cli.Tests/DiscordChatExporter.Cli.Tests.csproj Removed Version attributes from 12 package references while preserving PrivateAssets attributes

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

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

Copilot AI commented Feb 26, 2026

@copilot add the created Directory.Packages.props file to the sln file

Also, the docker build fails. Perhaps it's using an old SDK or otherwise doesn't support CPM?

Done in afab439:

  • Added Directory.Packages.props to the Misc solution folder in the .sln file.
  • Added COPY Directory.Packages.props . to the Dockerfile — the Docker build was failing because dotnet restore couldn't find the CPM props file that defines all package versions.

@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Feb 26, 2026

@copilot formatting fails

…butes

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

Copilot AI commented Feb 26, 2026

@copilot formatting fails

Fixed in 812192a. Removing the Version attribute from <PackageReference> elements with long Include names (e.g. Microsoft.Extensions.Configuration.EnvironmentVariables, Avalonia.Diagnostics) left them in multi-line XML form that was only needed when the line was longer. CSharpier now expects them collapsed to a single line. The two affected files (Cli.Tests.csproj and Gui.csproj) are updated accordingly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Tyrrrz Tyrrrz merged commit c593745 into master Feb 26, 2026
25 checks passed
@Tyrrrz Tyrrrz deleted the copilot/migrate-to-centralized-package-management branch February 26, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants