Skip to content

Commit 6a971f3

Browse files
committed
Improve calling vswhere
1 parent f22841b commit 6a971f3

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

extension/BuildPhpExtension/private/Add-VS.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function Add-Vs {
3333
New-Item -Path $installerDir -ItemType Directory -Force | Out-Null
3434
}
3535
Get-File -Url $vsWhereUrl -OutFile $vswherePath
36-
Add-Path $installerDir
3736
}
3837

3938
$instances = & $vswherePath -products '*' -format json 2> $null | ConvertFrom-Json

extension/BuildPhpExtension/private/Get-VsVersionHelper.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ function Get-VsVersionHelper {
1919
begin {
2020
}
2121
process {
22-
if($null -eq (Get-Command vswhere -ErrorAction SilentlyContinue)) {
22+
$installerDir = Join-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio" 'Installer'
23+
$vswherePath = Join-Path $installerDir 'vswhere.exe'
24+
if (-not (Test-Path $vswherePath)) {
2325
throw "vswhere is not available"
2426
}
25-
$MSVCDirectory = vswhere -latest -products * -find "VC\Tools\MSVC"
27+
$MSVCDirectory = & $vswherePath -latest -products * -find "VC\Tools\MSVC"
2628
$selectedToolset = $null
2729
$minor = $null
2830
foreach ($toolset in (Get-ChildItem $MSVCDirectory)) {

php/BuildPhp/private/Add-VS.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function Add-Vs {
2929
New-Item -Path $installerDir -ItemType Directory -Force | Out-Null
3030
}
3131
Get-File -Url $vsWhereUrl -OutFile $vswherePath
32-
Add-Path $installerDir
3332
}
3433

3534
$instances = & $vswherePath -products '*' -format json 2> $null | ConvertFrom-Json

php/BuildPhp/private/Get-VsVersionHelper.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ function Get-VsVersionHelper {
1919
begin {
2020
}
2121
process {
22-
if($null -eq (Get-Command vswhere -ErrorAction SilentlyContinue)) {
22+
$installerDir = Join-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio" 'Installer'
23+
$vswherePath = Join-Path $installerDir 'vswhere.exe'
24+
if (-not (Test-Path $vswherePath)) {
2325
throw "vswhere is not available"
2426
}
25-
$MSVCDirectory = vswhere -latest -products * -find "VC\Tools\MSVC"
27+
$MSVCDirectory = & $vswherePath -latest -products * -find "VC\Tools\MSVC"
2628
$selectedToolset = $null
2729
$minor = $null
2830
foreach ($toolset in (Get-ChildItem $MSVCDirectory)) {

0 commit comments

Comments
 (0)