From d89a60313b770a3574037c83faae916284443047 Mon Sep 17 00:00:00 2001 From: Todd Lehmann Date: Wed, 16 Aug 2017 09:27:55 -0700 Subject: [PATCH] Updated to Support VS Code x64 Installs Updated to Support VS Code x64 Installs --- scripts/Install-VSCode.ps1 | 103 ++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 42 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index b82e23749a..910e20ea33 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -92,50 +92,69 @@ #> [CmdletBinding()] param( - [Parameter()] - [ValidateNotNull()] - [string[]]$AdditionalExtensions = @(), + [Parameter()] + [ValidateNotNull()] + [string[]]$AdditionalExtensions = @(), - [switch]$LaunchWhenDone + [switch]$LaunchWhenDone, + + [switch]$Install32Bit ) -if (!($IsLinux -or $IsOSX)) { - - $codeCmdPath = "C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd" - - try { - $ProgressPreference = 'SilentlyContinue' - - if (!(Test-Path $codeCmdPath)) { - Write-Host "`nDownloading latest stable Visual Studio Code..." -ForegroundColor Yellow - Remove-Item -Force $env:TEMP\vscode-stable.exe -ErrorAction SilentlyContinue - Invoke-WebRequest -Uri https://vscode-update.azurewebsites.net/latest/win32/stable -OutFile $env:TEMP\vscode-stable.exe - - Write-Host "`nInstalling Visual Studio Code..." -ForegroundColor Yellow - Start-Process -Wait $env:TEMP\vscode-stable.exe -ArgumentList /silent, /mergetasks=!runcode - } - else { - Write-Host "`nVisual Studio Code is already installed." -ForegroundColor Yellow - } - - $extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions - foreach ($extension in $extensions) { - Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow - & $codeCmdPath --install-extension $extension - } - - if ($LaunchWhenDone) { - Write-Host "`nInstallation complete, starting Visual Studio Code...`n`n" -ForegroundColor Green - & $codeCmdPath - } - else { - Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green - } - } - finally { - $ProgressPreference = 'Continue' - } +if (!($IsLinux -or $IsOSX)) +{ + + $codeCmdPath = "C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd" + + try + { + $ProgressPreference = 'SilentlyContinue' + + if (!(Test-Path $codeCmdPath)) + { + Write-Host "`nDownloading latest stable Visual Studio Code..." -ForegroundColor Yellow + Remove-Item -Force $env:TEMP\vscode-stable.exe -ErrorAction SilentlyContinue + + $vsDownloadUri = 'https://go.microsoft.com/fwlink/?Linkid=852157' + + if ($Install32Bit.IsPresent) + { + $vsDownloadUri = 'https://vscode-update.azurewebsites.net/latest/win32/stable' + } + + Invoke-WebRequest -Uri $vsDownloadUri -OutFile $env:TEMP\vscode-stable.exe + + Write-Host "`nInstalling Visual Studio Code..." -ForegroundColor Yellow + Start-Process -Wait $env:TEMP\vscode-stable.exe -ArgumentList /silent, /mergetasks=!runcode + } + else + { + Write-Host "`nVisual Studio Code is already installed." -ForegroundColor Yellow + } + + $extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions + foreach ($extension in $extensions) + { + Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow + & $codeCmdPath --install-extension $extension + } + + if ($LaunchWhenDone) + { + Write-Host "`nInstallation complete, starting Visual Studio Code...`n`n" -ForegroundColor Green + & $codeCmdPath + } + else + { + Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green + } + } + finally + { + $ProgressPreference = 'Continue' + } } -else { - Write-Error "This script is currently only supported on the Windows operating system." +else +{ + Write-Error "This script is currently only supported on the Windows operating system." }