From 05485c7a253310c4b0778e06a729d99b59e55a83 Mon Sep 17 00:00:00 2001 From: Karol Kaczmarek Date: Fri, 22 Jul 2016 16:42:19 -0700 Subject: [PATCH] Confirming before installing choco and improving prompt message --- build.psm1 | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/build.psm1 b/build.psm1 index 6059589645..9524ab2727 100644 --- a/build.psm1 +++ b/build.psm1 @@ -602,24 +602,32 @@ function Start-PSBootstrap { # Install chocolatey $chocolateyPath = "$env:AllUsersProfile\chocolatey\bin" - if(precheck 'choco' $null) + if(precheck 'choco' $null) { log "Chocolatey is already installed. Skipping installation." } elseif(($cmakePresent -eq $false) -or ($sdkPresent -eq $false)) { 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()))) + if ($Force -or $PSCmdlet.ShouldProcess("Install chocolatey via https://chocolatey.org/install.ps1")) { - log "Adding $chocolateyPath to Path environment variable" - $env:Path += ";$chocolateyPath" - $newMachineEnvironmentPath += ";$chocolateyPath" + 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" + $newMachineEnvironmentPath += ";$chocolateyPath" + } + else + { + log "$chocolateyPath already present in Path environment variable" + } } else { - log "$chocolateyPath already present in Path environment variable" + Write-Error "Chocolatey is required to install missing dependencies. Please install it from https://chocolatey.org/ manually. Alternatively, install cmake and Windows 10 SDK." + return $null } } else @@ -667,7 +675,7 @@ function Start-PSBootstrap { if ($newMachineEnvironmentPath -ne $machinePath) { log "Updating Path machine environment variable" - if ($Force -or $PSCmdlet.ShouldProcess("Update Path machine environment variable")) + if ($Force -or $PSCmdlet.ShouldProcess("Update Path machine environment variable to $newMachineEnvironmentPath")) { [Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE') }