From e0f50b24905599578ca358f181a6b8e4a8d80fd5 Mon Sep 17 00:00:00 2001 From: Slan Date: Wed, 6 Jul 2022 03:18:45 +0100 Subject: Checks if MSVS 2019 or 2022 exists through reg key [skip ci] (#432) Co-authored-by: Vijay A --- scripts/build-windows.ps1 | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1 index 064eb026c..f0aeaee32 100644 --- a/scripts/build-windows.ps1 +++ b/scripts/build-windows.ps1 @@ -40,7 +40,6 @@ Function Test-CommandExists { Param ($command, $1) # Check for installed programmes Test-CommandExists node "Node is not installed" Test-CommandExists npm "npm is not installed" -# TODO: Needs proper way to check MSVS Build Tools # Check node version $EXPECTED_NODE_VERSION = (cat .nvmrc) @@ -94,14 +93,26 @@ if ($env:CLEAN -eq "true") # ----------------------------------------------------------------------------- # Ensure that the system dependencies are at the correct version - fail if not -# TODO: Needs proper way to check MSVS Tools # Check MSVS Tools through MSVS_VERSION -$EXPECTED_MSVST_VERSION = @("2019", "2022") -$ACTUAL_MSVST_VERSION = (npm config get msvs_version) -if (-not ($EXPECTED_MSVST_VERSION -contains $ACTUAL_MSVST_VERSION)) { +$EXPECTED_MSVST_VERSION = @("2019","2022") +$MSVS_REG_PATH = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup" + +if(-not (Test-Path -Path $MSVS_REG_PATH)){ + fail_with_docs "You don't have MSVS Tools Installed!" +} + +$MSVS_PATH = (Get-ItemProperty -Path $MSVS_REG_PATH).SharedInstallationPath | Split-Path + +Get-ChildItem($MSVS_PATH) | ForEach-Object{ + if($EXPECTED_MSVST_VERSION -contains $_){ + $ACTUAL_MSVST_VERSION = $_ + break + } +} + +if(-not $ACTUAL_MSVST_VERSION){ fail_with_docs "You are not running the expected version of MSVS Tools! - expected: [$EXPECTED_MSVST_VERSION] - actual : [$ACTUAL_MSVST_VERSION]" + expected: [$EXPECTED_MSVST_VERSION]" } # ----------------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2