25
25
.EXTERNALSCRIPTDEPENDENCIES
26
26
27
27
.RELEASENOTES
28
+ 15/08/2018 - added functionality to install the new "User Install" variant of Insiders Edition.
29
+ --
28
30
21/03/2018 - added functionality to install the VSCode context menus. Also, VSCode is now always added to the search path
29
31
--
30
32
20/03/2018 - fix OS detection to prevent error
57
59
downloaded instead. If parameter is not used, then 64-bit is used as default.
58
60
59
61
. PARAMETER BuildEdition
60
- A validated string defining which build edition or "stream" to download - stable or
61
- insiders edition. If the parameter is not used, then stable is downloaded as default.
62
+ A validated string defining which build edition or "stream" to download:
63
+ Stable or Insiders Edition (system install or user profile install).
64
+ If the parameter is not used, then stable is downloaded as default.
65
+
62
66
63
67
. PARAMETER AdditionalExtensions
64
68
An array of strings that are the fully-qualified names of extensions to be
91
95
extensions.
92
96
93
97
. EXAMPLE
94
- Install-VSCode.ps1 -BuildEdition Insider -LaunchWhenDone
98
+ Install-VSCode.ps1 -BuildEdition Insider-User -LaunchWhenDone
95
99
96
- Installs Visual Studio Code Insiders Edition (64-bit) and then launches the editor
100
+ Installs Visual Studio Code Insiders Edition (64-bit) to the user profile and then launches the editor
97
101
after installation completes.
98
102
99
103
. NOTES
122
126
[CmdletBinding ()]
123
127
param (
124
128
[parameter ()]
125
- [ValidateSet (, " 64-bit" , " 32-bit" )]
129
+ [ValidateSet (, " 64-bit" , " 32-bit" )]
126
130
[string ]$Architecture = " 64-bit" ,
127
131
128
132
[parameter ()]
129
- [ValidateSet (" stable" , " insider" )]
130
- [string ]$BuildEdition = " stable" ,
133
+ [ValidateSet (" Stable" , " Insider-System" , " Insider-User" )]
134
+ [string ]$BuildEdition = " Stable" ,
135
+
136
+ [Parameter ()]
137
+ [switch ]$User ,
131
138
132
139
[Parameter ()]
133
140
[ValidateNotNull ()]
@@ -153,7 +160,7 @@ if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
153
160
break ;
154
161
}
155
162
" 32-bit" {
156
- if ((Get-CimInstance - ClassName Win32_OperatingSystem).OSArchitecture -eq " 32-bit" ){
163
+ if ((Get-CimInstance - ClassName Win32_OperatingSystem).OSArchitecture -eq " 32-bit" ) {
157
164
$codePath = $env: ProgramFiles
158
165
$bitVersion = " win32"
159
166
}
@@ -168,11 +175,21 @@ if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
168
175
" Stable" {
169
176
$codeCmdPath = " $codePath \Microsoft VS Code\bin\code.cmd"
170
177
$appName = " Visual Studio Code ($ ( $Architecture ) )"
178
+ $fileUri = " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) /stable"
179
+
171
180
break ;
172
181
}
173
- " Insider" {
182
+ " Insider-System " {
174
183
$codeCmdPath = " $codePath \Microsoft VS Code Insiders\bin\code-insiders.cmd"
175
184
$appName = " Visual Studio Code - Insiders Edition ($ ( $Architecture ) )"
185
+ $fileUri = " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) /insider"
186
+
187
+ break ;
188
+ }
189
+ " Insider-User" {
190
+ $codeCmdPath = " $env: LocalAppData \Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd"
191
+ $appName = " Visual Studio Code - Insiders Edition ($ ( $Architecture ) - User)"
192
+ $fileUri = " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) -user/insider"
176
193
break ;
177
194
}
178
195
}
@@ -182,7 +199,21 @@ if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
182
199
if (! (Test-Path $codeCmdPath )) {
183
200
Write-Host " `n Downloading latest $appName ..." - ForegroundColor Yellow
184
201
Remove-Item - Force " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ErrorAction SilentlyContinue
185
- Invoke-WebRequest - Uri " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) /$ ( $BuildEdition ) " - OutFile " $env: TEMP \vscode-$ ( $BuildEdition ) .exe"
202
+ $bitsDl = Start-BitsTransfer $fileUri - Destination " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - Asynchronous
203
+ while (($bitsDL.JobState -eq " Transferring" ) -or ($bitsDL.JobState -eq " Connecting" )) {
204
+ Write-Progress - Activity " Downloading: $AppName " - Status " $ ( [math ]::round($bitsDl.BytesTransferred / 1 mb )) mb / $ ( [math ]::round($bitsDl.BytesTotal / 1 mb )) mb" - PercentComplete ($ ($bitsDl.BytesTransferred ) / $ ($bitsDl.BytesTotal ) * 100 )
205
+ }
206
+ switch ($bitsDl.JobSTate ) {
207
+ " Transferred" {
208
+ Complete-BitsTransfer - BitsJob $bitsDl
209
+ break ;
210
+ }
211
+ " Error" {
212
+ throw " Error downloading installation media."
213
+ break ;
214
+ }
215
+ }
216
+
186
217
187
218
Write-Host " `n Installing $appName ..." - ForegroundColor Yellow
188
219
if ($EnableContextMenus ) {
0 commit comments