diff --git a/BuildScripts/setup.ps1 b/BuildScripts/setup.ps1 index ba32d42e..7d807df8 100644 --- a/BuildScripts/setup.ps1 +++ b/BuildScripts/setup.ps1 @@ -216,6 +216,7 @@ function Create-Shortcut($location, $target, $targetArgs, $boxstarterPath) { Move-Item -Path $tempFile $location -Force } + function PersistBoxstarterPathToEnvironmentVariable($variableName, $boxstarterPath){ # Remove user scoped vars from previous releases $userValue = [Environment]::GetEnvironmentVariable($variableName, 'User') @@ -231,19 +232,24 @@ function PersistBoxstarterPathToEnvironmentVariable($variableName, $boxstarterPa $value = [Environment]::GetEnvironmentVariable($variableName, 'Machine') if($value){ $values=($value -split ';' | Where-Object { !($_.ToLower() -match "\\boxstarter$")}) -join ';' - $values="$boxstarterPath;$values" } elseif($variableName -eq "PSModulePath") { - $values = "$boxstarterPath;" - $values += [environment]::getfolderpath("ProgramFiles") + $values = [environment]::getfolderpath("ProgramFiles") $values +="\WindowsPowerShell\Modules" } else { $values ="$boxstarterPath" } + # explicitly add boxstarterPath at the end of the env-var! + if (($values -split ';') -inotcontains $boxstarterPath) { + $values += ";$boxstarterPath" + } + $values = $values.Replace(';;',';') [Environment]::SetEnvironmentVariable($variableName, $values, 'Machine') $varValue = Get-Content env:\$variableName - $varValue = "$boxstarterPath;$varValue" + if (($varValue -split ';') -inotcontains $boxstarterPath) { + $varValue += ";$boxstarterPath" + } Set-Content env:\$variableName -value $varValue }