11<# PSScriptInfo
22
3- .VERSION 1.0
3+ .VERSION 1.1
44
55.GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0
66
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
4447
4548 https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
4649
50+ . PARAMETER Architecture
51+ A validated string defining the bit version to download. Values can be either 64-bit or 32-bit.
52+ If 64-bit is chosen and the OS Architecture does not match, then the 32-bit build will be
53+ downloaded instead. If parameter is not used, then 64-bit is used as default.
54+
55+ . PARAMETER BuildEdition
56+ A validated string defining which build edition or "stream" to download - stable or
57+ insiders edition. If the parameter is not used, then stable is downloaded as default.
58+
4759. PARAMETER AdditionalExtensions
4860 An array of strings that are the fully-qualified names of extensions to be
4961 installed in addition to the PowerShell extension. The fully qualified
5567 When present, causes Visual Studio Code to be launched as soon as installation
5668 has finished.
5769
70+ . EXAMPLE
71+ Install-VSCode.ps1 -Architecture 32-bit
72+
73+ Installs Visual Studio Code (32-bit) and the powershell extension.
5874. EXAMPLE
5975 Install-VSCode.ps1 -LaunchWhenDone
6076
61- Installs Visual Studio Code and the PowerShell extension and then launches
77+ Installs Visual Studio Code (64-bit) and the PowerShell extension and then launches
6278 the editor after installation completes.
6379
6480. EXAMPLE
6581 Install-VSCode.ps1 -AdditionalExtensions 'eamodio.gitlens', 'vscodevim.vim'
6682
67- Installs Visual Studio Code, the PowerShell extension, and additional
83+ Installs Visual Studio Code (64-bit) , the PowerShell extension, and additional
6884 extensions.
6985
86+ . EXAMPLE
87+ Install-VSCode.ps1 -BuildEdition Insider -LaunchWhenDone
88+
89+ Installs Visual Studio Code Insiders Edition (64-bit) and then launches the editor
90+ after installation completes.
91+
7092. NOTES
7193 This script is licensed under the MIT License:
7294
92114#>
93115[CmdletBinding ()]
94116param (
117+ [parameter ()]
118+ [ValidateSet (, " 64-bit" , " 32-bit" )]
119+ [string ]$Architecture = " 64-bit" ,
120+
121+ [parameter ()]
122+ [ValidateSet (" stable" , " insider" )]
123+ [string ]$BuildEdition = " stable" ,
124+
95125 [Parameter ()]
96126 [ValidateNotNull ()]
97127 [string []]$AdditionalExtensions = @ (),
@@ -100,22 +130,56 @@ param(
100130)
101131
102132if (! ($IsLinux -or $IsOSX )) {
103-
104- $codeCmdPath = " C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd"
105-
133+ switch ($Architecture ) {
134+ " 64-bit" {
135+ if ((Get-CimInstance - ClassName Win32_OperatingSystem).OSArchitecture -eq " 64-bit" ) {
136+ $codePath = $env: ProgramFiles
137+ $bitVersion = " win32-x64"
138+ }
139+ else {
140+ $codePath = $env: ProgramFiles
141+ $bitVersion = " win32"
142+ $Architecture = " 32-bit"
143+ }
144+ break ;
145+ }
146+ " 32-bit" {
147+ if ((Get-CimInstance - ClassName Win32_OperatingSystem).OSArchitecture -eq " 32-bit" ){
148+ $codePath = $env: ProgramFiles
149+ $bitVersion = " win32"
150+ }
151+ else {
152+ $codePath = ${env: ProgramFiles(x86)}
153+ $bitVersion = " win32"
154+ }
155+ break ;
156+ }
157+ }
158+ switch ($BuildEdition ) {
159+ " Stable" {
160+ $codeCmdPath = " $codePath \Microsoft VS Code\bin\code.cmd"
161+ $appName = " Visual Studio Code ($ ( $Architecture ) )"
162+ break ;
163+ }
164+ " Insider" {
165+ $codeCmdPath = " $codePath \Microsoft VS Code Insiders\bin\code-insiders.cmd"
166+ $appName = " Visual Studio Code - Insiders Edition ($ ( $Architecture ) )"
167+ break ;
168+ }
169+ }
106170 try {
107171 $ProgressPreference = ' SilentlyContinue'
108172
109173 if (! (Test-Path $codeCmdPath )) {
110- Write-Host " `n Downloading 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
174+ Write-Host " `n Downloading latest $appName ..." - ForegroundColor Yellow
175+ Remove-Item - Force " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ErrorAction SilentlyContinue
176+ Invoke-WebRequest - Uri " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) / $ ( $BuildEdition ) " - OutFile " $env: TEMP \vscode-$ ( $BuildEdition ) .exe"
113177
114- Write-Host " `n Installing Visual Studio Code ..." - ForegroundColor Yellow
115- Start-Process - Wait $env: TEMP \vscode-stable .exe - ArgumentList / silent, / mergetasks= ! runcode
178+ Write-Host " `n Installing $appName ..." - ForegroundColor Yellow
179+ Start-Process - Wait " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ArgumentList / silent, / mergetasks= ! runcode
116180 }
117181 else {
118- Write-Host " `n Visual Studio Code is already installed." - ForegroundColor Yellow
182+ Write-Host " `n $appName is already installed." - ForegroundColor Yellow
119183 }
120184
121185 $extensions = @ (" ms-vscode.PowerShell" ) + $AdditionalExtensions
@@ -125,7 +189,7 @@ if (!($IsLinux -or $IsOSX)) {
125189 }
126190
127191 if ($LaunchWhenDone ) {
128- Write-Host " `n Installation complete, starting Visual Studio Code ...`n`n " - ForegroundColor Green
192+ Write-Host " `n Installation complete, starting $appName ...`n`n " - ForegroundColor Green
129193 & $codeCmdPath
130194 }
131195 else {
0 commit comments