From 6a989e86a970abb5a4e1397b12433305fe855860 Mon Sep 17 00:00:00 2001 From: Karol Kaczmarek Date: Thu, 21 Jul 2016 15:33:16 -0700 Subject: [PATCH] Installing chocolatey and updating machine path --- build.psm1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/build.psm1 b/build.psm1 index 85e66f5ef7..c8f7534342 100644 --- a/build.psm1 +++ b/build.psm1 @@ -589,6 +589,31 @@ function Start-PSBootstrap { $installScript = "dotnet-install.ps1" Invoke-WebRequest -Uri $obtainUrl/$installScript -OutFile $installScript & ./$installScript -c $Channel -v $Version + + # Install chocolatey + $machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE') + $chocolateyPath = "$env:AllUsersProfile\chocolatey\bin" + if(Get-Command "choco" -ErrorAction SilentlyContinue) + { + log "Chocolatey is already installed. Skipping installation." + } + else + { + log "Chocolatey not present. Installing chocolatey." + Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) + + if (-not ($machinePath.ToLower().Contains($chocolateyPath.ToLower()))) + { + log "Adding $chocolateyPath to Path environment variable" + $env:Path += ";$chocolateyPath" + $machinePath += ";$chocolateyPath" + [Environment]::SetEnvironmentVariable('Path', $machinePath, 'MACHINE') + } + else + { + log "$chocolateyPath already present in Path environment variable" + } + } } elseif ($IsWindows) { Write-Warning "Start-PSBootstrap cannot be run in Core PowerShell on Windows (need Invoke-WebRequest!)" }