Skip to content

Commit dfca251

Browse files
Ben ReaderBen Reader
Ben Reader
authored and
Ben Reader
committed
added 64bit support & vscode-insiders install support
1 parent 93bc21c commit dfca251

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

scripts/Install-VSCode.ps1

+31-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<#PSScriptInfo
22
3-
.VERSION 1.0
3+
.VERSION 1.1
44
55
.GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0
66
@@ -25,6 +25,9 @@
2525
.EXTERNALSCRIPTDEPENDENCIES
2626
2727
.RELEASENOTES
28+
28/12/2017 - added functionality to support 64-bit versions of VSCode
29+
& support for installation of VSCode Insiders Edition.
30+
--
2831
Initial release.
2932
#>
3033

@@ -44,6 +47,10 @@
4447
4548
https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
4649
50+
.PARAMETER BuildEdition
51+
A validated string defining which build edition or "stream" to download - stable or
52+
insiders edition. If the parameter is not used, then stable is downloaded as default.
53+
4754
.PARAMETER AdditionalExtensions
4855
An array of strings that are the fully-qualified names of extensions to be
4956
installed in addition to the PowerShell extension. The fully qualified
@@ -67,6 +74,12 @@
6774
Installs Visual Studio Code, the PowerShell extension, and additional
6875
extensions.
6976
77+
.EXAMPLE
78+
Install-VSCode.ps1 -BuildEdition Insider -LaunchWhenDone
79+
80+
Installs Visual Studio Code Insiders Edition and then launches the editor
81+
after installation completes.
82+
7083
.NOTES
7184
This script is licensed under the MIT License:
7285
@@ -92,27 +105,38 @@
92105
#>
93106
[CmdletBinding()]
94107
param(
108+
[parameter()]
109+
[ValidateSet("stable","insider")]
110+
[string]$BuildEdition = "stable",
95111
[Parameter()]
96112
[ValidateNotNull()]
97113
[string[]]$AdditionalExtensions = @(),
98-
99114
[switch]$LaunchWhenDone
100115
)
101116

102117
if (!($IsLinux -or $IsOSX)) {
118+
switch ($BuildEdition) {
119+
"Stable" {
120+
$codeCmdPath = "C:\Program*\Microsoft VS Code\bin\code.cmd"
121+
break;
122+
}
123+
"Insider" {
124+
$codeCmdPath = "C:\Program*\Microsoft VS Code Insiders\bin\code-insiders.cmd"
125+
break;
126+
}
127+
}
103128

104-
$codeCmdPath = "C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd"
105129

106130
try {
107131
$ProgressPreference = 'SilentlyContinue'
108132

109133
if (!(Test-Path $codeCmdPath)) {
110-
Write-Host "`nDownloading latest stable Visual Studio Code..." -ForegroundColor Yellow
111-
Remove-Item -Force $env:TEMP\vscode-stable.exe -ErrorAction SilentlyContinue
112-
Invoke-WebRequest -Uri https://vscode-update.azurewebsites.net/latest/win32/stable -OutFile $env:TEMP\vscode-stable.exe
134+
Write-Host "`nDownloading latest $($BuildEdition) Visual Studio Code..." -ForegroundColor Yellow
135+
Remove-Item -Force "$env:TEMP\vscode-$($BuildEdition).exe" -ErrorAction SilentlyContinue
136+
Invoke-WebRequest -Uri "https://vscode-update.azurewebsites.net/latest/win32-x64/$($BuildEdition)" -OutFile "$env:TEMP\vscode-$($BuildEdition).exe"
113137

114138
Write-Host "`nInstalling Visual Studio Code..." -ForegroundColor Yellow
115-
Start-Process -Wait $env:TEMP\vscode-stable.exe -ArgumentList /silent, /mergetasks=!runcode
139+
Start-Process -Wait "$env:TEMP\vscode-$($BuildEdition).exe" -ArgumentList /silent, /mergetasks=!runcode
116140
}
117141
else {
118142
Write-Host "`nVisual Studio Code is already installed." -ForegroundColor Yellow

0 commit comments

Comments
 (0)