build: change how we find the latest VC tools version (#18468)

Apparently, we were using the package containing the CRT _source code_
to determine the version of the tools.

Also apparently, VS does not guarantee that that package has the same
version as the tools package.

We should use the version of the tools package instead.
This commit is contained in:
Dustin L. Howett 2025-01-28 15:33:50 -06:00 committed by GitHub
parent 1040035b55
commit 8e4da6e938
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
$VSInstances = ([xml](& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -include packages -format xml))
$VSPackages = $VSInstances.instances.instance.packages.package
$LatestVCPackage = ($VSInstances.instances.instance.packages.package | ? { $_.id -eq "Microsoft.VisualCpp.CRT.Source" })
$LatestVCPackage = ($VSInstances.instances.instance.packages.package | ? { $_.id -eq "Microsoft.VisualCpp.Tools.Core" })
$LatestVCToolsVersion = $LatestVCPackage.version;
Write-Output "Latest VCToolsVersion: $LatestVCToolsVersion"