From 68d05af296412da21e1f56edc7dfd992e1e7b872 Mon Sep 17 00:00:00 2001 From: kishorekumar-anchala <168699259+kishorekumar-anchala@users.noreply.github.com> Date: Sun, 6 Apr 2025 05:37:45 +0000 Subject: [PATCH] [windows] Pin the cmake version to 3.31.6 (#11936) * [windows] Pin the cmake version to 3.31.6 * [windows] adjust choco script * Fix choco build failure * Add version parameter to choco script --- .../scripts/build/Install-ChocolateyPackages.ps1 | 2 +- images/windows/scripts/helpers/ChocoHelpers.ps1 | 13 ++++++++++--- images/windows/toolsets/toolset-2019.json | 1 + images/windows/toolsets/toolset-2022.json | 1 + images/windows/toolsets/toolset-2025.json | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/images/windows/scripts/build/Install-ChocolateyPackages.ps1 b/images/windows/scripts/build/Install-ChocolateyPackages.ps1 index 826e77ff9..12d0fc0ef 100644 --- a/images/windows/scripts/build/Install-ChocolateyPackages.ps1 +++ b/images/windows/scripts/build/Install-ChocolateyPackages.ps1 @@ -6,7 +6,7 @@ $commonPackages = (Get-ToolsetContent).choco.common_packages foreach ($package in $commonPackages) { - Install-ChocoPackage $package.name -ArgumentList $package.args + Install-ChocoPackage $package.name -Version $package.version -ArgumentList $package.args } Invoke-PesterTests -TestFile "ChocoPackages" diff --git a/images/windows/scripts/helpers/ChocoHelpers.ps1 b/images/windows/scripts/helpers/ChocoHelpers.ps1 index 610aee8fb..591156934 100644 --- a/images/windows/scripts/helpers/ChocoHelpers.ps1 +++ b/images/windows/scripts/helpers/ChocoHelpers.ps1 @@ -16,8 +16,11 @@ function Install-ChocoPackage { .PARAMETER RetryCount The number of times to retry the installation if it fails. Default is 5. + .PARAMETER Version + The version of the package to install. + .EXAMPLE - Install-ChocoPackage -PackageName "git" -RetryCount 3 + Install-ChocoPackage -PackageName "git" -Version "2.39.2" -RetryCount 3 #> [CmdletBinding()] @@ -25,6 +28,7 @@ function Install-ChocoPackage { [Parameter(Mandatory)] [string] $PackageName, [string[]] $ArgumentList, + [string] $Version, [int] $RetryCount = 5 ) @@ -32,8 +36,11 @@ function Install-ChocoPackage { $count = 1 while ($true) { Write-Host "Running [#$count]: choco install $packageName -y $argumentList" - choco install $packageName -y @argumentList --no-progress --require-checksums - + if ($Version) { + choco install $packageName --version $Version -y @ArgumentList --no-progress --require-checksums + } else { + choco install $packageName -y @ArgumentList --no-progress --require-checksums + } $pkg = choco list --localonly $packageName --exact --all --limitoutput if ($pkg) { Write-Host "Package installed: $pkg" diff --git a/images/windows/toolsets/toolset-2019.json b/images/windows/toolsets/toolset-2019.json index 86eabf756..cf8de603e 100644 --- a/images/windows/toolsets/toolset-2019.json +++ b/images/windows/toolsets/toolset-2019.json @@ -416,6 +416,7 @@ }, { "name": "cmake.install", + "version": "3.31.6", "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] }, { "name": "imagemagick" }, diff --git a/images/windows/toolsets/toolset-2022.json b/images/windows/toolsets/toolset-2022.json index 44f83f57d..cb7b69e5b 100644 --- a/images/windows/toolsets/toolset-2022.json +++ b/images/windows/toolsets/toolset-2022.json @@ -337,6 +337,7 @@ }, { "name": "cmake.install", + "version": "3.31.6", "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] }, { "name": "imagemagick" }, diff --git a/images/windows/toolsets/toolset-2025.json b/images/windows/toolsets/toolset-2025.json index c183c0600..b3ec20312 100644 --- a/images/windows/toolsets/toolset-2025.json +++ b/images/windows/toolsets/toolset-2025.json @@ -292,6 +292,7 @@ }, { "name": "cmake.install", + "version": "3.31.6", "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] }, {