From b696783a7eef96e2a28bb41bd3e287b77970141c Mon Sep 17 00:00:00 2001 From: Lothindir Date: Fri, 30 Aug 2019 15:38:30 +0200 Subject: [PATCH 1/7] Added functionality to install the User variant of Stable Edition --- scripts/Install-VSCode.ps1 | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 8dd3ab88ca..555e8909a5 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -1,6 +1,6 @@ <#PSScriptInfo -.VERSION 1.3 +.VERSION 1.3.1 .GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0 @@ -25,6 +25,8 @@ .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES + 30/08/2019 - added functionality to install the "User Install" variant of Stable Edition. + -- 07/11/2018 - added support for PowerShell Core and macOS/Linux platforms. -- 15/08/2018 - added functionality to install the new "User Install" variant of Insiders Edition. @@ -132,7 +134,7 @@ param( [string]$Architecture = "64-bit", [parameter()] - [ValidateSet("Stable", "Insider-System", "Insider-User")] + [ValidateSet("Stable","Stable-User", "Insider-System", "Insider-User")] [string]$BuildEdition = "Stable", [Parameter()] @@ -199,7 +201,7 @@ function Get-CodePlatformInformation { $Bitness, [Parameter(Mandatory=$true)] - [ValidateSet('Stable', 'Insider-System', 'Insider-User')] + [ValidateSet('Stable', 'Stable-User', 'Insider-System', 'Insider-User')] [string] $BuildEdition ) @@ -231,6 +233,11 @@ function Get-CodePlatformInformation { break } + 'Stable-User' { + $appName = "Visual Studio Code ($($Architecture) - User)" + break + } + 'Insider-System' { $appName = "Visual Studio Code - Insiders Edition ($Bitness)" break @@ -321,6 +328,9 @@ function Get-CodePlatformInformation { 'Stable' { $exePath = "$installBase\Microsoft VS Code\bin\code.cmd" } + 'Stable-User' { + $exePath = "${env:LocalAppData}\Programs\Microsoft VS Code\bin\code.cmd" + } 'Insider-System' { $exePath = "$installBase\Microsoft VS Code Insiders\bin\code-insiders.cmd" @@ -339,6 +349,12 @@ function Get-CodePlatformInformation { break } + 'Stable-User' { + $channel = 'stable' + $platform += '-user' + break + } + 'Insider-System' { $channel = 'insider' break From 544a208c0981887fe1a26a12ab04642b5647a8af Mon Sep 17 00:00:00 2001 From: Lothindir Date: Fri, 30 Aug 2019 16:20:00 +0200 Subject: [PATCH 2/7] Changed the BuildEdition parameter to comply with Issue #2048 Changed Stable to Stable-System as discussed in Issue #2048. --- scripts/Install-VSCode.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 555e8909a5..304467415e 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -134,8 +134,8 @@ param( [string]$Architecture = "64-bit", [parameter()] - [ValidateSet("Stable","Stable-User", "Insider-System", "Insider-User")] - [string]$BuildEdition = "Stable", + [ValidateSet("Stable-System","Stable-User", "Insider-System", "Insider-User")] + [string]$BuildEdition = "Stable-System", [Parameter()] [ValidateNotNull()] @@ -201,7 +201,7 @@ function Get-CodePlatformInformation { $Bitness, [Parameter(Mandatory=$true)] - [ValidateSet('Stable', 'Stable-User', 'Insider-System', 'Insider-User')] + [ValidateSet('Stable-System', 'Stable-User', 'Insider-System', 'Insider-User')] [string] $BuildEdition ) @@ -228,7 +228,7 @@ function Get-CodePlatformInformation { } switch ($BuildEdition) { - 'Stable' { + 'Stable-System' { $appName = "Visual Studio Code ($Bitness)" break } @@ -325,7 +325,7 @@ function Get-CodePlatformInformation { } switch ($BuildEdition) { - 'Stable' { + 'Stable-System' { $exePath = "$installBase\Microsoft VS Code\bin\code.cmd" } 'Stable-User' { @@ -344,7 +344,7 @@ function Get-CodePlatformInformation { } switch ($BuildEdition) { - 'Stable' { + 'Stable-System' { $channel = 'stable' break } @@ -455,7 +455,7 @@ function Install-VSCodeFromTar { # We need to be running as elevated on *nix if (($IsLinux -or $IsMacOS) -and (id -u) -ne 0) { - throw "Must be running as root to install VSCode.`nInvoke this script with (for example):`n`tsudo pwsh -f Install-VSCode.ps1 -BuildEdition Stable" + throw "Must be running as root to install VSCode.`nInvoke this script with (for example):`n`tsudo pwsh -f Install-VSCode.ps1 -BuildEdition Stable-System" } try { @@ -522,7 +522,7 @@ try { } switch ($BuildEdition) { - 'Stable' { + 'Stable-System' { & $pacMan install -y code } @@ -566,7 +566,7 @@ try { break } - Install-VSCodeFromTar -TarPath $installerPath -Insiders:($BuildEdition -ne 'Stable') + Install-VSCodeFromTar -TarPath $installerPath -Insiders:($BuildEdition -ne 'Stable-System') break } From 96adddaba9960f9ee9ad75cce20f84be4edc6213 Mon Sep 17 00:00:00 2001 From: Lothindir Date: Fri, 30 Aug 2019 16:29:44 +0200 Subject: [PATCH 3/7] Bump version to 1.4.0 --- scripts/Install-VSCode.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 304467415e..290fd09e72 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -1,6 +1,6 @@ <#PSScriptInfo -.VERSION 1.3.1 +.VERSION 1.4.0 .GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0 From 2db94cf82c6a20127cf980f85f7d1d52bb346ca6 Mon Sep 17 00:00:00 2001 From: Lothindir Date: Fri, 30 Aug 2019 16:30:43 +0200 Subject: [PATCH 4/7] Changed double quotes to single quotes when suitable Bumped version to 1.4.1 --- scripts/Install-VSCode.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 290fd09e72..1b83f8ea45 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -1,6 +1,6 @@ <#PSScriptInfo -.VERSION 1.4.0 +.VERSION 1.4.1 .GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0 @@ -130,11 +130,11 @@ [CmdletBinding(SupportsShouldProcess=$true)] param( [parameter()] - [ValidateSet(, "64-bit", "32-bit")] - [string]$Architecture = "64-bit", + [ValidateSet('64-bit', '32-bit')] + [string]$Architecture = '64-bit', [parameter()] - [ValidateSet("Stable-System","Stable-User", "Insider-System", "Insider-User")] + [ValidateSet('Stable-System', 'Stable-User', 'Insider-System', 'Insider-User')] [string]$BuildEdition = "Stable-System", [Parameter()] @@ -168,7 +168,7 @@ gpgkey=https://packages.microsoft.com/keys/microsoft.asc function Test-IsOsArchX64 { if ($PSVersionTable.PSVersion.Major -lt 6) { - return (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "64-bit" + return (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq '64-bit' } return [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture]::X64 @@ -404,19 +404,19 @@ function Save-WithBitsTransfer { $bitsDl = Start-BitsTransfer $FileUri -Destination $Destination -Asynchronous - while (($bitsDL.JobState -eq "Transferring") -or ($bitsDL.JobState -eq "Connecting")) { + while (($bitsDL.JobState -eq 'Transferring') -or ($bitsDL.JobState -eq 'Connecting')) { Write-Progress -Activity "Downloading: $AppName" -Status "$([math]::round($bitsDl.BytesTransferred / 1mb))mb / $([math]::round($bitsDl.BytesTotal / 1mb))mb" -PercentComplete ($($bitsDl.BytesTransferred) / $($bitsDl.BytesTotal) * 100 ) } switch ($bitsDl.JobState) { - "Transferred" { + 'Transferred' { Complete-BitsTransfer -BitsJob $bitsDl break } - "Error" { - throw "Error downloading installation media." + 'Error' { + throw 'Error downloading installation media.' } } } @@ -433,7 +433,7 @@ function Install-VSCodeFromTar { ) $tarDir = Join-Path ([System.IO.Path]::GetTempPath()) 'VSCodeTar' - $destDir = "/opt/VSCode-linux-x64" + $destDir = '/opt/VSCode-linux-x64' New-Item -ItemType Directory -Force -Path $tarDir try { From f7095bc01b5a2c9b76ed72d0c9a4ffcabe7800a6 Mon Sep 17 00:00:00 2001 From: cesco Date: Sat, 31 Aug 2019 00:44:05 +0200 Subject: [PATCH 5/7] Change version Co-Authored-By: Tyler James Leonhardt --- scripts/Install-VSCode.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 1b83f8ea45..27aaf3aaa6 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -1,6 +1,6 @@ <#PSScriptInfo -.VERSION 1.4.1 +.VERSION 1.4 .GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0 From 69096e8d59541a44311bddaa35a9f79aad48cf03 Mon Sep 17 00:00:00 2001 From: Lothindir Date: Mon, 2 Sep 2019 09:14:50 +0200 Subject: [PATCH 6/7] Added error msg when the $BuildEdition ends in User but we're not on Win Added error message when the $BuildEdition ends in User but we're on Linux or MacOS --- scripts/Install-VSCode.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 27aaf3aaa6..54de6cdf18 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -458,6 +458,11 @@ if (($IsLinux -or $IsMacOS) -and (id -u) -ne 0) { throw "Must be running as root to install VSCode.`nInvoke this script with (for example):`n`tsudo pwsh -f Install-VSCode.ps1 -BuildEdition Stable-System" } +# User builds can only be installed on Windows systems +if ($BuildEdition.EndsWith('User') -and -not ($IsWindows -or $PSVersionTable.PSVersion.Major -lt 5)) { + throw 'User builds are not available for non-Windows systems' +} + try { $prevProgressPreference = $ProgressPreference $ProgressPreference = 'SilentlyContinue' From 46a729391bb57b7a918ab5e2765475a12df96a9e Mon Sep 17 00:00:00 2001 From: cesco Date: Tue, 3 Sep 2019 07:48:36 +0200 Subject: [PATCH 7/7] Added newline Co-Authored-By: Tyler James Leonhardt --- scripts/Install-VSCode.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 54de6cdf18..46c3ca8049 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -328,6 +328,7 @@ function Get-CodePlatformInformation { 'Stable-System' { $exePath = "$installBase\Microsoft VS Code\bin\code.cmd" } + 'Stable-User' { $exePath = "${env:LocalAppData}\Programs\Microsoft VS Code\bin\code.cmd" }