Skip to content

Updated to Support VS Code x64 Installs #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 61 additions & 42 deletions scripts/Install-VSCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}