aboutsummaryrefslogtreecommitdiffstats
path: root/coin
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2022-11-17 07:24:56 +0100
committerOliver Wolff <oliver.wolff@qt.io>2023-03-24 08:50:58 +0100
commite83e6f73f968b325373dca08a12c1a8373a371d1 (patch)
tree938b5ea1c4180f917d9cfd1fcb17a254fb5ec7af /coin
parenta03b71324b5737a122c08d5a3d141ea69525f2fa (diff)
Provisioning: MSVC 2019 update: Add Vswhere helper function6.4
Change-Id: Idd6bf24450d9447c38c39c64abff5b55d71c12b9 Reviewed-by: Miguel Costa <miguel.costa@qt.io> (cherry picked from commit 37c0cf82aeffd08678f702d49377652605778679)
Diffstat (limited to 'coin')
-rw-r--r--coin/provisioning/common/windows/update-msvc2019.ps154
1 files changed, 48 insertions, 6 deletions
diff --git a/coin/provisioning/common/windows/update-msvc2019.ps1 b/coin/provisioning/common/windows/update-msvc2019.ps1
index 7a482f01..3ab94582 100644
--- a/coin/provisioning/common/windows/update-msvc2019.ps1
+++ b/coin/provisioning/common/windows/update-msvc2019.ps1
@@ -73,15 +73,57 @@ function Install {
Remove-Item -Force -Path $installerPath
}
+function Get-Vswhere-Property {
+ Param (
+ [ValidateSet(2017, 2019, 2022)]
+ [int] $vsYear = $(BadParam("Visual Studio Year")),
+
+ [ValidatePattern("Professional|Build *Tools|Community|Enterprise")]
+ [string] $vsEdition = $(BadParam("Visual Studio Edition")),
+
+ [string] $property = $(BadParam("vswhere property"))
+ )
+
+ $range = switch ($vsYear)
+ {
+ 2017 { "[15.0,16`)" }
+ 2019 { "[16.0,17`)" }
+ 2022 { "[17.0,18`)" }
+ }
+
+ $vsEdition = $vsEdition -replace " ",""
+
+ $vswhereInfo = New-Object System.Diagnostics.ProcessStartInfo
+ $vswhereInfo.FileName = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
+ $vswhereInfo.RedirectStandardError = $true
+ $vswhereInfo.RedirectStandardOutput = $true
+ $vswhereInfo.UseShellExecute = $false
+ $vswhereInfo.Arguments = "-version $range", "-latest", `
+ "-products Microsoft.VisualStudio.Product.$vsEdition", "-property $property"
+ $vswhereProcess = New-Object System.Diagnostics.Process
+ $vswhereProcess.StartInfo = $vswhereInfo
+ $vswhereProcess.Start() | Out-Null
+ $vswhereProcess.WaitForExit()
+ $stdout = $vswhereProcess.StandardOutput.ReadToEnd()
+ if ([string]::IsNullOrEmpty($stdout))
+ {
+ throw "VS edition or property $property not found by vswhere"
+ }
+ $stderr = $vswhereProcess.StandardError.ReadToEnd()
+ $vsExit = $vswhereProcess.ExitCode
+ if ($vsExit -ne 0)
+ {
+ throw "vswhere failed with exit code $vsExit. stderr: $stderr"
+ }
+ return $stdout
+}
+
Install $urlOfficial_vsInstaller $urlCache_vsInstaller $sha1_vsInstaller
# Install $urlOfficial_buildToolsInstaller $urlCache_buildToolsInstaller $sha1_buildToolsInstaller
-$msvc2019Version = (cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" `
- -version [16.0,17.0`) -latest -property catalog_productDisplayVersion 2`>`&1)
-$msvc2019Complete = (cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" `
- -version [16.0,17.0`) -latest -property isComplete 2`>`&1)
-$msvc2019Launchable = (cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" `
- -version [16.0,17.0`) -latest -property isLaunchable 2`>`&1)
+$msvc2019Version = Get-Vswhere-Property 2019 "Professional" catalog_productDisplayVersion
+$msvc2019Complete = Get-Vswhere-Property 2019 "Professional" isComplete
+$msvc2019Launchable = Get-Vswhere-Property 2019 "Professional" isLaunchable
if($msvc2019Version -ne $version -or [int]$msvc2019Complete -ne 1 `
-or [int]$msvc2019Launchable -ne 1) {