From f58afd5476ab6695961ef127da4427371004723c Mon Sep 17 00:00:00 2001 From: Pavel Dubsky Date: Tue, 7 Mar 2023 14:35:24 +0100 Subject: [PATCH] Use vswhere to find the location of Visual Studio vswhere tool is included since Visual Studio 2017 and is always located at the same path thus making it a more convenient way to find Visual Studio install directory. Pick-to: 6.5 Change-Id: I680af8f88779841108b436223b4667f8a7c91aba Reviewed-by: Artem Dyomin Reviewed-by: Lars Knoll --- coin/provisioning/common/windows/helpers.ps1 | 9 +++++++++ coin/provisioning/common/windows/install-ffmpeg.ps1 | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/coin/provisioning/common/windows/helpers.ps1 b/coin/provisioning/common/windows/helpers.ps1 index 1967b02a..d27b2fd6 100644 --- a/coin/provisioning/common/windows/helpers.ps1 +++ b/coin/provisioning/common/windows/helpers.ps1 @@ -274,3 +274,12 @@ function DeleteSchedulerTask { Write-Host "Disabling $Task from Task Scheduler" SCHTASKS /DELETE /TN "Microsoft\Windows\$Task" /F } + +function GetVSPath { + Param ( + [string]$VSWhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe", + [string]$Component = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" + ) + + return (& $VSWhere -nologo -latest -products * -requires $Component -property installationPath) +} diff --git a/coin/provisioning/common/windows/install-ffmpeg.ps1 b/coin/provisioning/common/windows/install-ffmpeg.ps1 index 42fb26d2..3bca2520 100644 --- a/coin/provisioning/common/windows/install-ffmpeg.ps1 +++ b/coin/provisioning/common/windows/install-ffmpeg.ps1 @@ -107,8 +107,7 @@ function InstallMingwFfmpeg { function InstallMsvcFfmpeg { - $vsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional" - #$vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional" + $vsPath = GetVSPath Write-Host "Enter VisualStudio developer shell" try {