1
1
<# PSScriptInfo
2
2
3
- .VERSION 1.3
3
+ .VERSION 1.4
4
4
5
5
.GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0
6
6
25
25
.EXTERNALSCRIPTDEPENDENCIES
26
26
27
27
.RELEASENOTES
28
+ 30/08/2019 - added functionality to install the "User Install" variant of Stable Edition.
29
+ --
28
30
07/11/2018 - added support for PowerShell Core and macOS/Linux platforms.
29
31
--
30
32
15/08/2018 - added functionality to install the new "User Install" variant of Insiders Edition.
128
130
[CmdletBinding (SupportsShouldProcess = $true )]
129
131
param (
130
132
[parameter ()]
131
- [ValidateSet (, " 64-bit" , " 32-bit" )]
132
- [string ]$Architecture = " 64-bit" ,
133
+ [ValidateSet (' 64-bit' , ' 32-bit' )]
134
+ [string ]$Architecture = ' 64-bit' ,
133
135
134
136
[parameter ()]
135
- [ValidateSet (" Stable" , " Insider-System" , " Insider-User" )]
136
- [string ]$BuildEdition = " Stable" ,
137
+ [ValidateSet (' Stable-System ' , ' Stable-User ' , ' Insider-System' , ' Insider-User' )]
138
+ [string ]$BuildEdition = " Stable-System " ,
137
139
138
140
[Parameter ()]
139
141
[ValidateNotNull ()]
@@ -166,7 +168,7 @@ gpgkey=https://packages.microsoft.com/keys/microsoft.asc
166
168
167
169
function Test-IsOsArchX64 {
168
170
if ($PSVersionTable.PSVersion.Major -lt 6 ) {
169
- return (Get-CimInstance - ClassName Win32_OperatingSystem).OSArchitecture -eq " 64-bit"
171
+ return (Get-CimInstance - ClassName Win32_OperatingSystem).OSArchitecture -eq ' 64-bit'
170
172
}
171
173
172
174
return [System.Runtime.InteropServices.RuntimeInformation ]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture ]::X64
@@ -199,7 +201,7 @@ function Get-CodePlatformInformation {
199
201
$Bitness ,
200
202
201
203
[Parameter (Mandatory = $true )]
202
- [ValidateSet (' Stable' , ' Insider-System' , ' Insider-User' )]
204
+ [ValidateSet (' Stable-System ' , ' Stable-User ' , ' Insider-System' , ' Insider-User' )]
203
205
[string ]
204
206
$BuildEdition
205
207
)
@@ -226,11 +228,16 @@ function Get-CodePlatformInformation {
226
228
}
227
229
228
230
switch ($BuildEdition ) {
229
- ' Stable' {
231
+ ' Stable-System ' {
230
232
$appName = " Visual Studio Code ($Bitness )"
231
233
break
232
234
}
233
235
236
+ ' Stable-User' {
237
+ $appName = " Visual Studio Code ($ ( $Architecture ) - User)"
238
+ break
239
+ }
240
+
234
241
' Insider-System' {
235
242
$appName = " Visual Studio Code - Insiders Edition ($Bitness )"
236
243
break
@@ -318,10 +325,14 @@ function Get-CodePlatformInformation {
318
325
}
319
326
320
327
switch ($BuildEdition ) {
321
- ' Stable' {
328
+ ' Stable-System ' {
322
329
$exePath = " $installBase \Microsoft VS Code\bin\code.cmd"
323
330
}
324
331
332
+ ' Stable-User' {
333
+ $exePath = " ${env: LocalAppData} \Programs\Microsoft VS Code\bin\code.cmd"
334
+ }
335
+
325
336
' Insider-System' {
326
337
$exePath = " $installBase \Microsoft VS Code Insiders\bin\code-insiders.cmd"
327
338
}
@@ -334,11 +345,17 @@ function Get-CodePlatformInformation {
334
345
}
335
346
336
347
switch ($BuildEdition ) {
337
- ' Stable' {
348
+ ' Stable-System ' {
338
349
$channel = ' stable'
339
350
break
340
351
}
341
352
353
+ ' Stable-User' {
354
+ $channel = ' stable'
355
+ $platform += ' -user'
356
+ break
357
+ }
358
+
342
359
' Insider-System' {
343
360
$channel = ' insider'
344
361
break
@@ -388,19 +405,19 @@ function Save-WithBitsTransfer {
388
405
389
406
$bitsDl = Start-BitsTransfer $FileUri - Destination $Destination - Asynchronous
390
407
391
- while (($bitsDL.JobState -eq " Transferring" ) -or ($bitsDL.JobState -eq " Connecting" )) {
408
+ while (($bitsDL.JobState -eq ' Transferring' ) -or ($bitsDL.JobState -eq ' Connecting' )) {
392
409
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 )
393
410
}
394
411
395
412
switch ($bitsDl.JobState ) {
396
413
397
- " Transferred" {
414
+ ' Transferred' {
398
415
Complete-BitsTransfer - BitsJob $bitsDl
399
416
break
400
417
}
401
418
402
- " Error" {
403
- throw " Error downloading installation media."
419
+ ' Error' {
420
+ throw ' Error downloading installation media.'
404
421
}
405
422
}
406
423
}
@@ -417,7 +434,7 @@ function Install-VSCodeFromTar {
417
434
)
418
435
419
436
$tarDir = Join-Path ([System.IO.Path ]::GetTempPath()) ' VSCodeTar'
420
- $destDir = " /opt/VSCode-linux-x64"
437
+ $destDir = ' /opt/VSCode-linux-x64'
421
438
422
439
New-Item - ItemType Directory - Force - Path $tarDir
423
440
try {
@@ -439,7 +456,12 @@ function Install-VSCodeFromTar {
439
456
440
457
# We need to be running as elevated on *nix
441
458
if (($IsLinux -or $IsMacOS ) -and (id - u) -ne 0 ) {
442
- throw " Must be running as root to install VSCode.`n Invoke this script with (for example):`n`t sudo pwsh -f Install-VSCode.ps1 -BuildEdition Stable"
459
+ throw " Must be running as root to install VSCode.`n Invoke this script with (for example):`n`t sudo pwsh -f Install-VSCode.ps1 -BuildEdition Stable-System"
460
+ }
461
+
462
+ # User builds can only be installed on Windows systems
463
+ if ($BuildEdition.EndsWith (' User' ) -and -not ($IsWindows -or $PSVersionTable.PSVersion.Major -lt 5 )) {
464
+ throw ' User builds are not available for non-Windows systems'
443
465
}
444
466
445
467
try {
@@ -506,7 +528,7 @@ try {
506
528
}
507
529
508
530
switch ($BuildEdition ) {
509
- ' Stable' {
531
+ ' Stable-System ' {
510
532
& $pacMan install - y code
511
533
}
512
534
@@ -550,7 +572,7 @@ try {
550
572
break
551
573
}
552
574
553
- Install-VSCodeFromTar - TarPath $installerPath - Insiders:($BuildEdition -ne ' Stable' )
575
+ Install-VSCodeFromTar - TarPath $installerPath - Insiders:($BuildEdition -ne ' Stable-System ' )
554
576
break
555
577
}
556
578
0 commit comments