File tree Expand file tree Collapse file tree 4 files changed +33
-0
lines changed
extension/BuildPhpExtension/private Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ function Add-Vs {
33
33
New-Item - Path $installerDir - ItemType Directory - Force | Out-Null
34
34
}
35
35
Get-File - Url $vsWhereUrl - OutFile $vswherePath
36
+ Add-Path $installerDir
36
37
}
37
38
38
39
$instances = & $vswherePath - products ' *' - format json 2> $null | ConvertFrom-Json
Original file line number Diff line number Diff line change 64
64
# Private functions
65
65
' Add-BuildRequirements' ,
66
66
' Add-TestRequirements' ,
67
+ ' Add-Path' ,
67
68
' Add-Vs' ,
68
69
' Get-File' ,
69
70
' Get-OciSdk' ,
Original file line number Diff line number Diff line change
1
+ Function Add-Path {
2
+ <#
3
+ . SYNOPSIS
4
+ Add a directory to PATH environment variable.
5
+ . PARAMETER PathItem
6
+ The directory to add to PATH.
7
+ #>
8
+ [OutputType ()]
9
+ param (
10
+ [Parameter (Mandatory = $true , Position = 0 , HelpMessage = ' Path to Add' )]
11
+ [ValidateNotNull ()]
12
+ [ValidateLength (1 , [int ]::MaxValue)]
13
+ [string ] $PathItem
14
+ )
15
+ begin {
16
+ }
17
+ process {
18
+ $currentUserPath = [System.Environment ]::GetEnvironmentVariable(" PATH" , [System.EnvironmentVariableTarget ]::User)
19
+ $machinePath = [System.Environment ]::GetEnvironmentVariable(" PATH" , [System.EnvironmentVariableTarget ]::Machine)
20
+ $currentPath = $currentUserPath + " ;" + $machinePath
21
+ if (-not ($currentPath.Split (' ;' ).Contains(($PathItem + " ;" )))) {
22
+ $newUserPath = $PathItem + " ;" + $currentUserPath
23
+ [System.Environment ]::SetEnvironmentVariable(" PATH" , $newUserPath , [System.EnvironmentVariableTarget ]::User)
24
+ $machinePath = [System.Environment ]::GetEnvironmentVariable(" PATH" , [System.EnvironmentVariableTarget ]::Machine)
25
+ $env: PATH = $newUserPath + " ;" + $machinePath
26
+ }
27
+ }
28
+ end {
29
+ }
30
+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ function Add-Vs {
29
29
New-Item - Path $installerDir - ItemType Directory - Force | Out-Null
30
30
}
31
31
Get-File - Url $vsWhereUrl - OutFile $vswherePath
32
+ Add-Path $installerDir
32
33
}
33
34
34
35
$instances = & $vswherePath - products ' *' - format json 2> $null | ConvertFrom-Json
You can’t perform that action at this time.
0 commit comments