11<# PSScriptInfo
22
3- .VERSION 1.3
3+ .VERSION 1.4
44
55.GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0
66
2525.EXTERNALSCRIPTDEPENDENCIES
2626
2727.RELEASENOTES
28+ 30/08/2019 - added functionality to install the "User Install" variant of Stable Edition.
29+ --
2830 07/11/2018 - added support for PowerShell Core and macOS/Linux platforms.
2931 --
3032 15/08/2018 - added functionality to install the new "User Install" variant of Insiders Edition.
128130[CmdletBinding (SupportsShouldProcess = $true )]
129131param (
130132 [parameter ()]
131- [ValidateSet (, " 64-bit" , " 32-bit" )]
132- [string ]$Architecture = " 64-bit" ,
133+ [ValidateSet (' 64-bit' , ' 32-bit' )]
134+ [string ]$Architecture = ' 64-bit' ,
133135
134136 [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 " ,
137139
138140 [Parameter ()]
139141 [ValidateNotNull ()]
@@ -166,7 +168,7 @@ gpgkey=https://packages.microsoft.com/keys/microsoft.asc
166168
167169function Test-IsOsArchX64 {
168170 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'
170172 }
171173
172174 return [System.Runtime.InteropServices.RuntimeInformation ]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture ]::X64
@@ -199,7 +201,7 @@ function Get-CodePlatformInformation {
199201 $Bitness ,
200202
201203 [Parameter (Mandatory = $true )]
202- [ValidateSet (' Stable' , ' Insider-System' , ' Insider-User' )]
204+ [ValidateSet (' Stable-System ' , ' Stable-User ' , ' Insider-System' , ' Insider-User' )]
203205 [string ]
204206 $BuildEdition
205207 )
@@ -226,11 +228,16 @@ function Get-CodePlatformInformation {
226228 }
227229
228230 switch ($BuildEdition ) {
229- ' Stable' {
231+ ' Stable-System ' {
230232 $appName = " Visual Studio Code ($Bitness )"
231233 break
232234 }
233235
236+ ' Stable-User' {
237+ $appName = " Visual Studio Code ($ ( $Architecture ) - User)"
238+ break
239+ }
240+
234241 ' Insider-System' {
235242 $appName = " Visual Studio Code - Insiders Edition ($Bitness )"
236243 break
@@ -318,10 +325,14 @@ function Get-CodePlatformInformation {
318325 }
319326
320327 switch ($BuildEdition ) {
321- ' Stable' {
328+ ' Stable-System ' {
322329 $exePath = " $installBase \Microsoft VS Code\bin\code.cmd"
323330 }
324331
332+ ' Stable-User' {
333+ $exePath = " ${env: LocalAppData} \Programs\Microsoft VS Code\bin\code.cmd"
334+ }
335+
325336 ' Insider-System' {
326337 $exePath = " $installBase \Microsoft VS Code Insiders\bin\code-insiders.cmd"
327338 }
@@ -334,11 +345,17 @@ function Get-CodePlatformInformation {
334345 }
335346
336347 switch ($BuildEdition ) {
337- ' Stable' {
348+ ' Stable-System ' {
338349 $channel = ' stable'
339350 break
340351 }
341352
353+ ' Stable-User' {
354+ $channel = ' stable'
355+ $platform += ' -user'
356+ break
357+ }
358+
342359 ' Insider-System' {
343360 $channel = ' insider'
344361 break
@@ -388,19 +405,19 @@ function Save-WithBitsTransfer {
388405
389406 $bitsDl = Start-BitsTransfer $FileUri - Destination $Destination - Asynchronous
390407
391- while (($bitsDL.JobState -eq " Transferring" ) -or ($bitsDL.JobState -eq " Connecting" )) {
408+ while (($bitsDL.JobState -eq ' Transferring' ) -or ($bitsDL.JobState -eq ' Connecting' )) {
392409 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 )
393410 }
394411
395412 switch ($bitsDl.JobState ) {
396413
397- " Transferred" {
414+ ' Transferred' {
398415 Complete-BitsTransfer - BitsJob $bitsDl
399416 break
400417 }
401418
402- " Error" {
403- throw " Error downloading installation media."
419+ ' Error' {
420+ throw ' Error downloading installation media.'
404421 }
405422 }
406423}
@@ -417,7 +434,7 @@ function Install-VSCodeFromTar {
417434 )
418435
419436 $tarDir = Join-Path ([System.IO.Path ]::GetTempPath()) ' VSCodeTar'
420- $destDir = " /opt/VSCode-linux-x64"
437+ $destDir = ' /opt/VSCode-linux-x64'
421438
422439 New-Item - ItemType Directory - Force - Path $tarDir
423440 try {
@@ -439,7 +456,12 @@ function Install-VSCodeFromTar {
439456
440457# We need to be running as elevated on *nix
441458if (($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'
443465}
444466
445467try {
@@ -506,7 +528,7 @@ try {
506528 }
507529
508530 switch ($BuildEdition ) {
509- ' Stable' {
531+ ' Stable-System ' {
510532 & $pacMan install - y code
511533 }
512534
@@ -550,7 +572,7 @@ try {
550572 break
551573 }
552574
553- Install-VSCodeFromTar - TarPath $installerPath - Insiders:($BuildEdition -ne ' Stable' )
575+ Install-VSCodeFromTar - TarPath $installerPath - Insiders:($BuildEdition -ne ' Stable-System ' )
554576 break
555577 }
556578
0 commit comments