1
1
<# PSScriptInfo
2
2
3
- .VERSION 1.0
3
+ .VERSION 1.1
4
4
5
5
.GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0
6
6
25
25
.EXTERNALSCRIPTDEPENDENCIES
26
26
27
27
.RELEASENOTES
28
+ 28/12/2017 - added functionality to support 64-bit versions of VSCode
29
+ & support for installation of VSCode Insiders Edition.
30
+ --
28
31
Initial release.
29
32
#>
30
33
44
47
45
48
https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
46
49
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
+
47
59
. PARAMETER AdditionalExtensions
48
60
An array of strings that are the fully-qualified names of extensions to be
49
61
installed in addition to the PowerShell extension. The fully qualified
55
67
When present, causes Visual Studio Code to be launched as soon as installation
56
68
has finished.
57
69
70
+ . EXAMPLE
71
+ Install-VSCode.ps1 -Architecture 32-bit
72
+
73
+ Installs Visual Studio Code (32-bit) and the powershell extension.
58
74
. EXAMPLE
59
75
Install-VSCode.ps1 -LaunchWhenDone
60
76
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
62
78
the editor after installation completes.
63
79
64
80
. EXAMPLE
65
81
Install-VSCode.ps1 -AdditionalExtensions 'eamodio.gitlens', 'vscodevim.vim'
66
82
67
- Installs Visual Studio Code, the PowerShell extension, and additional
83
+ Installs Visual Studio Code (64-bit) , the PowerShell extension, and additional
68
84
extensions.
69
85
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
+
70
92
. NOTES
71
93
This script is licensed under the MIT License:
72
94
92
114
#>
93
115
[CmdletBinding ()]
94
116
param (
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
+
95
125
[Parameter ()]
96
126
[ValidateNotNull ()]
97
127
[string []]$AdditionalExtensions = @ (),
@@ -100,22 +130,56 @@ param(
100
130
)
101
131
102
132
if (! ($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
+ }
106
170
try {
107
171
$ProgressPreference = ' SilentlyContinue'
108
172
109
173
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"
113
177
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
116
180
}
117
181
else {
118
- Write-Host " `n Visual Studio Code is already installed." - ForegroundColor Yellow
182
+ Write-Host " `n $appName is already installed." - ForegroundColor Yellow
119
183
}
120
184
121
185
$extensions = @ (" ms-vscode.PowerShell" ) + $AdditionalExtensions
@@ -125,7 +189,7 @@ if (!($IsLinux -or $IsOSX)) {
125
189
}
126
190
127
191
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
129
193
& $codeCmdPath
130
194
}
131
195
else {
0 commit comments