Skip to content

Commit df465e7

Browse files
committed
add Get-VisualStudio-Installs
1 parent df2782f commit df465e7

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

Build-Unreal-AutoSDK.ps1

+4-11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ param(
3131
)
3232

3333
. ".\Get-AutoSDK-PlatformPath.ps1"
34+
. ".\Get-VisualStudio-Installs.ps1"
3435

3536
$AutoSDKRoot = Get-Item -Path $Path -ErrorAction SilentlyContinue
3637
if (-not $AutoSDKRoot) {
@@ -50,23 +51,15 @@ if ($Clean) {
5051
Write-Output "Cleaning AutoSDK platform path: $AutoSDKPlatformPath"
5152
Remove-Item -Path $AutoSDKPlatformPath -Recurse -Force
5253
}
53-
$pf = [Environment]::GetFolderPath("ProgramFilesx86")
54-
Write-Output "Program Files: $pf"
55-
# TODO: if powershell 7 use Join-Path enhancements instead of [IO.Path]::Combine?
56-
# $vsWhere = Join-Path $pf "Microsoft Visual Studio" "Installer" "vswhere.exe"
57-
$vsWhere = [IO.Path]::Combine($pf, "Microsoft Visual Studio", "Installer", "vswhere.exe")
58-
Write-Output "vsWhere path: $vsWhere"
59-
if (-not (Test-Path $vsWhere)) {
60-
Write-Error "vsWhere not found -- are you sure you are running on a machine with Visual Studio 2017 or better installed?"
61-
Exit -1
62-
}
63-
$VSInstalls = (& "$vsWhere" -format json -all -requires Microsoft.Component.MSBuild | ConvertFrom-Json) #-all -products * -requires Microsoft.VisualStudio.Product.BuildTools -property installationPath | ConvertFrom-Json
54+
55+
$VSInstalls = Get-VisualStudio-Installs
6456
Write-Information "Visual Studio installs: $($VSInstalls.Count)"
6557
if ($VSInstalls.Count -eq 0) {
6658
Write-Error "No Visual Studio installs found"
6759
Exit -1
6860
}
6961
Write-Verbose "Visual Studio install 1: $($VSInstalls[0])"
62+
7063
$VSInstalls | ForEach-Object {
7164
$vsPath = $_.installationPath
7265
$vsVersion = $_.buildVersion

Get-VisualStudio-Installs.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function Get-VisualStudio-Installs {
2+
$pf = [Environment]::GetFolderPath('ProgramFilesx86') # couldn't figure out the correct syntax to do this from string interpolation
3+
$vsWhere = [IO.Path]::Combine($pf, 'Microsoft Visual Studio', 'Installer', 'vswhere.exe')
4+
if (-not (Test-Path $vsWhere)) {
5+
throw "Could not find vswhere.exe at $vsWhere - are you sure Visual Studio 2017+ is installed?"
6+
}
7+
8+
$vsWhereArgs = @(
9+
'-format'
10+
'json'
11+
'-all'
12+
'-latest'
13+
'-requires'
14+
'Microsoft.Component.MSBuild'
15+
)
16+
& $vsWhere @vsWhereArgs | ConvertFrom-Json
17+
}

0 commit comments

Comments
 (0)