Update C++ nuget package references using new scripts#5877
Update C++ nuget package references using new scripts#5877JohnMcPMS merged 5 commits intomicrosoft:masterfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
| <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.targets'))" /> | ||
| </Target> | ||
| </Project> | ||
|
|
|
|
||
| [CmdletBinding()] | ||
| param( | ||
| [ValidateSet("Table", "CSV", "JSON", "Object")] |
There was a problem hiding this comment.
Do we need all of these? I don't see why we would ever use anything but Object
| [ValidateSet("Table", "CSV", "JSON", "Object")] | ||
| [string]$OutputFormat = "Table", | ||
|
|
||
| [string]$ExportPath, |
There was a problem hiding this comment.
Do we need this? If I want to write to file I can just | Out-File (and apply whatever format I want inbetween)
| try { | ||
| $vcxprojFiles = Get-ChildItem -Path $SearchPath -Filter "*.vcxproj" -Recurse -ErrorAction SilentlyContinue | ||
| if (-not $SuppressOutput) { | ||
| Write-Host "Found $($vcxprojFiles.Count) .vcxproj files" -ForegroundColor Green |
| $packages = @() | ||
|
|
||
| if (-not (Test-Path $PackagesConfigPath)) { | ||
| Write-Verbose "No packages.config found for project: $ProjectName" |
There was a problem hiding this comment.
The AI does know about Write-Verbose!
|
|
||
| # Main execution | ||
| try { | ||
| $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path |
| Shows what changes would be made without actually making them. | ||
|
|
||
| .PARAMETER Backup | ||
| Creates backup files (.bak) before making changes. |
There was a problem hiding this comment.
It wanted to default that on...
| $oldPattern = [regex]::Escape("$PackageName.$OldVersion") | ||
| $newPattern = "$PackageName.$NewVersion" |
There was a problem hiding this comment.
Probably not much of a concern, but this wouldn't work if a package adds a props or targets file in the new version.
There was a problem hiding this comment.
Yes, I'm expecting that if that happens we will have to apply it to a single project and then figure out how to get that into the rest of them. On the plus side, the Get script makes for an easier starting point.
florelis
left a comment
There was a problem hiding this comment.
I don't like some things about it, but if it works well enough and we're not shipping it...
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
-PackageFilterto target a specific package. It gives you a link to the package on nuget.org to use in the update script.Update-VcxprojNugetPackageVersions
This script updates a single package to a new version across all projects. It supports
-WhatIfto 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).Microsoft Reviewers: Open in CodeFlow