Skip to content

Use Centralized Nuget Package Management for vcxproj - #579

Merged
Gordon Lam (yeelam-gordon) merged 27 commits into
release/experimentalfrom
user/yeelam/CentralizedNuget
Dec 25, 2025
Merged

Use Centralized Nuget Package Management for vcxproj#579
Gordon Lam (yeelam-gordon) merged 27 commits into
release/experimentalfrom
user/yeelam/CentralizedNuget

Conversation

@yeelam-gordon

@yeelam-gordon Gordon Lam (yeelam-gordon) commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Description

This pull request modernizes the NuGet package management approach for the C++ Win32 and Console Activation sample projects. The changes migrate the projects from using the legacy packages.config and explicit .props/.targets imports to the newer PackageReference style, simplifying dependency management and project files.

Key changes include:

Migration to PackageReference style:

  • Updated all vcxproj to use the PackageReference NuGet style, including new properties such as RestoreProjectStyle, NuGetTargetMoniker, and platform-specific identifiers. This change streamlines NuGet package handling and aligns with modern Visual Studio practices.

  • Added direct <PackageReference> entries for Microsoft.WindowsAppSDK and Microsoft.Windows.CppWinRT in the CppWinRtConsoleActivation.vcxproj file, replacing the need for explicit version management and manual imports.

Cleanup of legacy NuGet configuration:

  • Removed the packages.config file and its reference from the project, fully deprecating the old NuGet package management mechanism. [1] [2]

  • Deleted all explicit .props and .targets imports, as well as the custom NuGet error-checking target, from the project files. These are now handled automatically by the PackageReference system, reducing clutter and potential for misconfiguration. [1] [2] [3]

These updates make the projects easier to maintain and ensure compatibility with current and future Visual Studio tooling.

Target Release

Please specify which release this PR should align with 2.0

Checklist

Note that /azp run currently isn't working for this repo.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 modernizes NuGet package management across C++ sample projects by migrating from the legacy packages.config approach to the modern PackageReference style with centralized version management. This change simplifies dependency management, reduces project file complexity, and aligns with current Visual Studio and MSBuild best practices.

  • Migrates all C++ .vcxproj projects to use PackageReference-style NuGet management
  • Removes all packages.config files and associated manual Import statements
  • Updates UpdateVersions.ps1 to remove obsolete packages.config processing logic
  • Enables centralized package version management through Directory.Packages.props
  • Removes C# project version attributes to rely on centralized management

Reviewed changes

Copilot reviewed 172 out of 222 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
UpdateVersions.ps1 Simplified package installation logic; removed packages.config, vcxproj, wapproj, and csproj version update code blocks
Multiple .vcxproj files Added NuGet PackageReference properties, added PackageReference elements, removed Import statements and packages.config references
Multiple packages.config files Deleted (migration to PackageReference)
Directory.Build.props files Added MSBuild warning suppressions and centralized package management settings
Directory.Packages.props Updated package versions; removed granular WindowsAppSDK sub-packages
Multiple .csproj/.wapproj files Removed explicit Version attributes to use centralized versions

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

Comment thread Samples/WindowsML/cpp/CppConsoleDll/WindowsMLWrapper/WindowsMLWrapper.vcxproj Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 214 out of 312 changed files in this pull request and generated 23 comments.


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

Comment thread Samples/Unpackaged/cpp-console-unpackaged/Unpackaged.vcxproj Outdated
Comment thread Samples/Unpackaged/cpp-console-unpackaged/Unpackaged.vcxproj Outdated
Comment thread Samples/TextRendering/cpp-win32/DWriteCoreGallery/DWriteCoreGallery.vcxproj Outdated
Comment thread Samples/TextRendering/cpp-win32/DWriteCoreGallery/DWriteCoreGallery.vcxproj Outdated
Comment thread Samples/Notifications/Push/cpp-console-packaged/cpp-console.vcxproj Outdated
Comment thread Samples/Notifications/Badge/cpp-winui/cpp-winui.vcxproj
Comment thread Samples/Notifications/Badge/cpp-winui/cpp-winui.vcxproj Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 214 out of 312 changed files in this pull request and generated no new comments.


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

@yeelam-gordon
Gordon Lam (yeelam-gordon) marked this pull request as ready for review December 25, 2025 02:56
@yeelam-gordon
Gordon Lam (yeelam-gordon) merged commit 0d035e0 into release/experimental Dec 25, 2025
4 checks passed
@yeelam-gordon
Gordon Lam (yeelam-gordon) deleted the user/yeelam/CentralizedNuget branch December 25, 2025 06:32
haonanttt pushed a commit that referenced this pull request Feb 6, 2026
* Built successful one in 1st round

* Untried one, but AI converted

* 2nd Fix

* 3rd changes

* 4th Fix

* Fix WinML build issue

* 5th fix

* Fix  WindowsAISample.csproj restore nuget problem

* Fix further build issue

* Ensure only 1 newline, not multiple, for csproj and vcxproj

* Try to have reliable version update for Directory.Packages.props

* Test failure because the waproj doesn't reference correct MSVCP

* Fix build error for CsWpfState/CsWpfState.csproj

* Fix CppWinMainEnv failed to launch with error VCRuntime140_1.dll not found

* Add missing VCRForwarders

* Fix copilot comment

* Convert WinUI3 to single package - starting with Instancing

* Update the rest to be single package

* pdateVersions.ps1 should restore package even when packages folder not provided

* Remove all vcxproj.filters's packages.config reference

* Restore some of original property - phase 1

* Restore original packages path

* Remove extra symbols

* Restore originally appxmanifest value for those migrated one

* remove unnecessary property in Directory.Build.props for WinML

* Add warning only if restore not successful

* Nuget install on pipeline will be done itself, it cannot fail
haonanttt added a commit that referenced this pull request Feb 6, 2026
…) (#590)

* Built successful one in 1st round

* Untried one, but AI converted

* 2nd Fix

* 3rd changes

* 4th Fix

* Fix WinML build issue

* 5th fix

* Fix  WindowsAISample.csproj restore nuget problem

* Fix further build issue

* Ensure only 1 newline, not multiple, for csproj and vcxproj

* Try to have reliable version update for Directory.Packages.props

* Test failure because the waproj doesn't reference correct MSVCP

* Fix build error for CsWpfState/CsWpfState.csproj

* Fix CppWinMainEnv failed to launch with error VCRuntime140_1.dll not found

* Add missing VCRForwarders

* Fix copilot comment

* Convert WinUI3 to single package - starting with Instancing

* Update the rest to be single package

* pdateVersions.ps1 should restore package even when packages folder not provided

* Remove all vcxproj.filters's packages.config reference

* Restore some of original property - phase 1

* Restore original packages path

* Remove extra symbols

* Restore originally appxmanifest value for those migrated one

* remove unnecessary property in Directory.Build.props for WinML

* Add warning only if restore not successful

* Nuget install on pipeline will be done itself, it cannot fail

Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com>
@adrastogi

Copy link
Copy Markdown
Contributor

Gordon Lam (@yeelam-gordon) would this change be eventually ported to main as well? It looks like the build strategies have diverged between the two branches.

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

Labels

None yet

4 participants