-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added functionality to install the User variant of Stable Edition #2160
Changes from all commits
b696783
544a208
96addda
2db94cf
f7095bc
69096e8
46a7293
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<#PSScriptInfo | ||
|
||
.VERSION 1.3 | ||
.VERSION 1.4 | ||
|
||
.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. | ||
|
@@ -128,12 +130,12 @@ | |
[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", "Insider-System", "Insider-User")] | ||
[string]$BuildEdition = "Stable", | ||
[ValidateSet('Stable-System', 'Stable-User', 'Insider-System', 'Insider-User')] | ||
[string]$BuildEdition = "Stable-System", | ||
|
||
[Parameter()] | ||
[ValidateNotNull()] | ||
|
@@ -166,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 | ||
|
@@ -199,7 +201,7 @@ function Get-CodePlatformInformation { | |
$Bitness, | ||
|
||
[Parameter(Mandatory=$true)] | ||
[ValidateSet('Stable', 'Insider-System', 'Insider-User')] | ||
[ValidateSet('Stable-System', 'Stable-User', 'Insider-System', 'Insider-User')] | ||
[string] | ||
$BuildEdition | ||
) | ||
|
@@ -226,11 +228,16 @@ function Get-CodePlatformInformation { | |
} | ||
|
||
switch ($BuildEdition) { | ||
'Stable' { | ||
'Stable-System' { | ||
$appName = "Visual Studio Code ($Bitness)" | ||
break | ||
} | ||
|
||
'Stable-User' { | ||
$appName = "Visual Studio Code ($($Architecture) - User)" | ||
break | ||
} | ||
|
||
'Insider-System' { | ||
$appName = "Visual Studio Code - Insiders Edition ($Bitness)" | ||
break | ||
|
@@ -318,10 +325,14 @@ function Get-CodePlatformInformation { | |
} | ||
|
||
switch ($BuildEdition) { | ||
'Stable' { | ||
'Stable-System' { | ||
$exePath = "$installBase\Microsoft VS Code\bin\code.cmd" | ||
} | ||
|
||
'Stable-User' { | ||
Lothindir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$exePath = "${env:LocalAppData}\Programs\Microsoft VS Code\bin\code.cmd" | ||
} | ||
|
||
'Insider-System' { | ||
$exePath = "$installBase\Microsoft VS Code Insiders\bin\code-insiders.cmd" | ||
} | ||
|
@@ -334,11 +345,17 @@ function Get-CodePlatformInformation { | |
} | ||
|
||
switch ($BuildEdition) { | ||
'Stable' { | ||
'Stable-System' { | ||
$channel = 'stable' | ||
break | ||
} | ||
|
||
'Stable-User' { | ||
$channel = 'stable' | ||
$platform += '-user' | ||
break | ||
} | ||
|
||
'Insider-System' { | ||
$channel = 'insider' | ||
break | ||
|
@@ -388,19 +405,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.' | ||
} | ||
} | ||
} | ||
|
@@ -417,7 +434,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 { | ||
|
@@ -439,7 +456,12 @@ function Install-VSCodeFromTar { | |
|
||
# We need to be running as elevated on *nix | ||
if (($IsLinux -or $IsMacOS) -and (id -u) -ne 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like In that case, you might want to add another error message here when the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a similar check at line 226. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b696783 |
||
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" | ||
} | ||
|
||
# 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 { | ||
|
@@ -506,7 +528,7 @@ try { | |
} | ||
|
||
switch ($BuildEdition) { | ||
'Stable' { | ||
'Stable-System' { | ||
& $pacMan install -y code | ||
} | ||
|
||
|
@@ -550,7 +572,7 @@ try { | |
break | ||
} | ||
|
||
Install-VSCodeFromTar -TarPath $installerPath -Insiders:($BuildEdition -ne 'Stable') | ||
Install-VSCodeFromTar -TarPath $installerPath -Insiders:($BuildEdition -ne 'Stable-System') | ||
break | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you used
$Architecture
here instead of$Bitness
like System?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I did the same as the Insiders Edition - user install.