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 {
3333 New-Item - Path $installerDir - ItemType Directory - Force | Out-Null
3434 }
3535 Get-File - Url $vsWhereUrl - OutFile $vswherePath
36+ Add-Path $installerDir
3637 }
3738
3839 $instances = & $vswherePath - products ' *' - format json 2> $null | ConvertFrom-Json
Original file line number Diff line number Diff line change 6464 # Private functions
6565 ' Add-BuildRequirements' ,
6666 ' Add-TestRequirements' ,
67+ ' Add-Path' ,
6768 ' Add-Vs' ,
6869 ' Get-File' ,
6970 ' 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 {
2929 New-Item - Path $installerDir - ItemType Directory - Force | Out-Null
3030 }
3131 Get-File - Url $vsWhereUrl - OutFile $vswherePath
32+ Add-Path $installerDir
3233 }
3334
3435 $instances = & $vswherePath - products ' *' - format json 2> $null | ConvertFrom-Json
You can’t perform that action at this time.
0 commit comments