Update C++ nuget package references using new scripts by JohnMcPMS · Pull Request #5877 · microsoft/winget-cli

Change

Adds scripts to view the nuget package references in C++ projects and update them en-masse. Use them to update C++/WinRT and WIL to the latest version.

Get-VcxprojNugetPackageVersions

This script lets you get the set of packages in use by all C++ projects. You can provide a -PackageFilter to target a specific package. It gives you a link to the package on nuget.org to use in the update script.

> .\src\Get-VcxprojNugetPackageVersions.ps1
Starting search from: D:\winget-cli\src
Output format: Table
Found 48 .vcxproj files

=== PACKAGE DETAILS ===

Name                                                  Count
----                                                  -----
Microsoft.Windows.CppWinRT, 2.0.250303.1                 13
Microsoft.Windows.ImplementationLibrary, 1.0.250325.1    15


=== PACKAGE URLS ===
  Microsoft.Windows.CppWinRT : https://www.nuget.org/packages/Microsoft.Windows.CppWinRT#versions-body-tab
  Microsoft.Windows.ImplementationLibrary : https://www.nuget.org/packages/Microsoft.Windows.ImplementationLibrary#versions-body-tab

=== PROJECT DETAILS ===

ProjectName                                  PackageId                               Version      TargetFramework
-----------                                  ---------                               -------      ---------------
AppInstallerCLI                              Microsoft.Windows.CppWinRT              2.0.250303.1 native
[... removed full list for brevity ...]
UndockedRegFreeWinRT                         Microsoft.Windows.ImplementationLibrary 1.0.250325.1 native


=== SUMMARY ===
Total .vcxproj files found: 48
Projects with packages.config: 16
Projects without packages.config: 32
Total package references: 28

Script completed.

Update-VcxprojNugetPackageVersions

This script updates a single package to a new version across all projects. It supports -WhatIf to inspect what will happen before doing it (although I would always suggest running it on a clean git state so that you can undo easily).

> .\Update-VcxprojNugetPackageVersions.ps1 -PackageName Microsoft.Windows.ImplementationLibrary -NewVersion 1.0.250325.1
Starting package version update process...
Package: Microsoft.Windows.ImplementationLibrary
New Version: 1.0.250325.1
Backup files: Disabled

Searching for projects using package 'Microsoft.Windows.ImplementationLibrary'...
Found 15 reference(s) to package 'Microsoft.Windows.ImplementationLibrary'

Projects to update:
  AppInstallerCLICore - Version(s): 1.0.231028.1
[... removed full list for brevity ...]
  UndockedRegFreeWinRT - Version(s): 1.0.231028.1

Starting updates...
Updated packages.config: D:\winget-cli\src\AppInstallerCLICore\packages.config
  Microsoft.Windows.ImplementationLibrary: 1.0.231028.11.0.250325.1
Updated .vcxproj file: D:\winget-cli\src\AppInstallerCLICore\AppInstallerCLICore.vcxproj
  Replaced 4 reference(s): Microsoft\.Windows\.ImplementationLibrary\.1\.0\.231028\.1 → Microsoft.Windows.ImplementationLibrary.1.0.250325.1
[... removed full list for brevity ...]

=== UPDATE SUMMARY ===
Package: Microsoft.Windows.ImplementationLibrary
New Version: 1.0.250325.1
Projects found with package: 15
packages.config files updated: 15
.vcxproj files updated: 15

Versions being replaced:
  1.0.231028.1 (in 15 project(s))

Update process completed!
Microsoft Reviewers: Open in CodeFlow