From 2143d7248aac4ca37e87d1944a562b544b492400 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 31 Oct 2018 19:27:08 -0700 Subject: [PATCH 01/22] Make VSCode install script cross-plat --- scripts/Install-VSCode.ps1 | 406 +++++++++++++++++++++++++++++-------- 1 file changed, 327 insertions(+), 79 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 8efcc9a1ff..bbae1f9d0e 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -133,9 +133,6 @@ param( [ValidateSet("Stable", "Insider-System", "Insider-User")] [string]$BuildEdition = "Stable", - [Parameter()] - [switch]$User, - [Parameter()] [ValidateNotNull()] [string[]]$AdditionalExtensions = @(), @@ -145,106 +142,357 @@ param( [switch]$EnableContextMenus ) -if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) { - switch ($Architecture) { - "64-bit" { - if ((Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "64-bit") { - $codePath = $env:ProgramFiles - $bitVersion = "win32-x64" - } - else { - $codePath = $env:ProgramFiles - $bitVersion = "win32" - $Architecture = "32-bit" - } - break; - } - "32-bit" { - if ((Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "32-bit") { - $codePath = $env:ProgramFiles - $bitVersion = "win32" - } - else { - $codePath = ${env:ProgramFiles(x86)} - $bitVersion = "win32" - } - break; - } +function Test-IsOsX64 +{ + if ($PSVersionTable.PSVersion.Major -lt 6) + { + return (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "64-bit" } - switch ($BuildEdition) { - "Stable" { - $codeCmdPath = "$codePath\Microsoft VS Code\bin\code.cmd" - $appName = "Visual Studio Code ($($Architecture))" - $fileUri = "https://vscode-update.azurewebsites.net/latest/$($bitVersion)/stable" - break; + return [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture]::X64 +} + +function Get-LinuxReleaseInfo +{ + if (-not (Test-Path '/etc/*-release')) + { + return $null + } + + return Get-Content -Raw '/etc/*-release' -ErrorAction SilentlyContinue ` + | ConvertFrom-Csv -Delimiter '=' -Header 'Key','Value' ` + | ForEach-Object { $obj = @{} } { $obj[$_.Key] = $_.Value } { [pscustomobject]$obj } +} + +function Get-CodePlatformInformation { + param( + [Parameter(Mandatory=$true)] + [ValidateSet('32-bit', '64-bit')] + [string] + $Bitness, + + [Parameter(Mandatory=$true)] + [ValidateSet('Stable', 'Insider-System', 'Insider-User')] + [string] + $BuildEdition + ) + + if ($IsWindows -or $PSVersionTable.PSVersion.Major -lt 6) { + $os = 'Windows' + } + elseif ($IsLinux) { + $os = 'Linux' + } + elseif ($IsMacOS) { + $os = 'MacOS' + } + else { + throw 'Could not identify operating system' + } + + if ($Bitness -ne '64-bit' -and $os -ne 'Windows') { + throw "Non-64-bit *nix systems are not supported" + } + + if ($BuildEdition.EndsWith('User') -and $os -ne 'Windows') { + throw 'User builds are not available for non-Windows systems' + } + + switch ($BuildEdition) { + 'Stable' { + $appName = "Visual Studio Code ($Bitness)" + break } - "Insider-System" { - $codeCmdPath = "$codePath\Microsoft VS Code Insiders\bin\code-insiders.cmd" - $appName = "Visual Studio Code - Insiders Edition ($($Architecture))" - $fileUri = "https://vscode-update.azurewebsites.net/latest/$($bitVersion)/insider" - break; + 'Insider-System' { + $appName = "Visual Studio Code - Insiders Edition ($Bitness)" + break } - "Insider-User" { - $codeCmdPath = "$env:LocalAppData\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd" + + 'Insider-User' { $appName = "Visual Studio Code - Insiders Edition ($($Architecture) - User)" - $fileUri = "https://vscode-update.azurewebsites.net/latest/$($bitVersion)-user/insider" - break; + break } } - try { - $ProgressPreference = 'SilentlyContinue' - - if (!(Test-Path $codeCmdPath)) { - Write-Host "`nDownloading latest $appName..." -ForegroundColor Yellow - Remove-Item -Force "$env:TEMP\vscode-$($BuildEdition).exe" -ErrorAction SilentlyContinue - $bitsDl = Start-BitsTransfer $fileUri -Destination "$env:TEMP\vscode-$($BuildEdition).exe" -Asynchronous - 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" { - Complete-BitsTransfer -BitsJob $bitsDl - break; + + switch ($os) { + 'Linux' { + $releaseInfo = Get-LinuxReleaseInfo + + switch ($releaseInfo.NAME) { + { 'Ubuntu','Debian' -contains $_ } { + $platform = 'linux-deb-x64' + $ext = 'deb' + break + } + + { 'Fedora','CentOS','RedHat' -contains $_ } { + $platform = 'linux-rpm-x64' + $ext = 'deb' + break } - "Error" { - throw "Error downloading installation media." - break; + + default { + $platform = 'linux-x64' + $ext = 'tar.gz' + break } } + if ($BuildEdition.StartsWith('Insider')) { + $exePath = '/usr/bin/code-insiders' + break + } - Write-Host "`nInstalling $appName..." -ForegroundColor Yellow - if ($EnableContextMenus) { - Start-Process -Wait "$env:TEMP\vscode-$($BuildEdition).exe" -ArgumentList "/verysilent /tasks=addcontextmenufiles,addcontextmenufolders,addtopath" + $exePath = '/usr/bin/code' + break + } + + 'MacOS' { + $platform = 'darwin' + $ext = 'zip' + + if ($BuildEdition.StartsWith('Insider')) { + $exePath = '/usr/local/bin/code-insiders' + break } - else { - Start-Process -Wait "$env:TEMP\vscode-$($BuildEdition).exe" -ArgumentList "/verysilent /tasks=addtopath" + + $exePath = '/usr/local/bin/code' + break + } + + 'Windows' { + $ext = 'exe' + switch ($Bitness) { + '32-bit' { + $platform = 'win32' + + if (Test-IsOsX64) { + $installBase = ${env:ProgramFiles(x86)} + break + } + + $installBase = ${env:ProgramFiles} + break + } + + '64-bit' { + $installBase = ${env:ProgramFiles} + + if (Test-IsOsX64) { + $platform = 'win32-x64' + break + } + + Write-Warning '64-bit install requested on 32-bit system. Installing 32-bit VSCode' + $platform = 'win32' + break + } + } + + switch ($BuildEdition) { + 'Stable' { + $exePath = "$installBase\Microsoft VS Code\bin\code.cmd" + } + + 'Insiders-System' { + $exePath = "$installBase\Microsoft VS Code Insiders\bin\code-insiders.cmd" + } + + 'Insiders-User' { + $exePath = "${env:LocalAppData}\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd" + } } } - else { - Write-Host "`n$appName is already installed." -ForegroundColor Yellow + } + + switch ($BuildEdition) + { + 'Stable' { + $channel = 'stable' + break } - $extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions - foreach ($extension in $extensions) { - Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow - & $codeCmdPath --install-extension $extension + 'Insiders-System' { + $channel = 'insider' + break } - if ($LaunchWhenDone) { - Write-Host "`nInstallation complete, starting $appName...`n`n" -ForegroundColor Green - & $codeCmdPath + 'Insiders-User' { + $channel = 'insider' + $platform += '-user' + break } - else { - Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green + } + + $info = @{ + AppName = $appName + ExePath = $exePath + Platform = $platform + Channel = $channel + FileUri = "https://vscode-update.azurewebsites.net/latest/$platform/$channel" + Extension = $ext + } + + return $info +} + +function Save-WithBitsTransfer { + param( + [Parameter(Mandatory=$true)] + [string] + $FileUri, + + [Parameter(Mandatory=$true)] + [string] + $Destination, + + [Parameter(Mandatory=$true)] + [string] + $AppName + ) + + Write-Host "`nDownloading latest $AppName..." -ForegroundColor Yellow + + Remove-Item -Force $Destination -ErrorAction SilentlyContinue + + $bitsDl = Start-BitsTransfer $FileUri -Destination $Destination -Asynchronous + + 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" { + Complete-BitsTransfer -BitsJob $bitsDl + break } + + "Error" { + throw "Error downloading installation media." + } + } +} + +function Install-VSCodeFromTar { + param( + [Parameter(Mandatory=$true)] + [string] + $TarPath, + + [Parameter()] + [switch] + $Insiders + ) + + $tarDir = Join-Path ([System.IO.Path]::GetTempPath()) 'VSCodeTar' + $destDir = "/opt/VSCode-linux-x64" + + New-Item -ItemType Directory -Force -Path $tarDir + try { + Push-Location $tarDir + tar xf $TarPath + Move-Item -LiteralPath "$tarDir/VSCode-linux-x64" $destDir } finally { - $ProgressPreference = 'Continue' + Pop-Location + } + + if ($Insiders) { + ln -s "$destDir/code-insiders" /usr/bin/code-insiders + return } + + ln -s "$destDir/code" /usr/bin/code } -else { - Write-Error "This script is currently only supported on the Windows operating system." + +try +{ + $prevProgressPreference = $ProgressPreference + + $onWindows = $IsWindows -or $PSVersionTable.PSVersion.Major -lt 6 + + # Get information required for installation + $codePlatformInfo = Get-CodePlatformInformation -Bitness $Architecture -BuildEdition $BuildEdition + + # Download the installer + $tmpdir = [System.IO.Path]::GetTempPath() + + $installerName = "vscode-install.$ext" + + $installerPath = [System.IO.Path]::Combine($tmpdir, $installerName) + + if ($onWindows) { + Save-WithBitsTransfer -FileUri $codePlatformInfo.FileUri -Destination $installerPath -AppName $codePlatformInfo.AppName + } + else { + Invoke-WebRequest -Uri $FileUri -OutFile $installerPath + } + + # Install VSCode + switch ($codePlatformInfo.Extension) { + # On Debian-like Linux distros + 'deb' { + apt install $installerPath + break + } + + # On RedHat-list Linux distros + 'rpm' { + rpm -ivh $installerPath + break + } + + # On Windows + 'exe' { + if ($EnableContextMenus) { + Start-Process -Wait $installerPath -ArgumentList "/verysilent /tasks=addcontextmenufiles,addcontextmenufolders,addtopath" + break + } + + Start-Process -Wait $installerPath -ArgumentList "/verysilent /tasks=addtopath" + break + } + + # On Mac + 'zip' { + $zipDirPath = [System.IO.Path]::Combine($tmpdir, 'VSCode') + Expand-Archive -LiteralPath $installerPath -DestinationPath $zipDirPath -Force + Move-Item "$zipDirPath/*.app" '/Applications/' + break + } + + # Remaining Linux distros using tar - more complicated + 'tar.gz' { + Install-VSCodeFromTar -TarPath $installerPath -Insiders:($BuildEdition -ne 'Stable') + break + } + + default { + throw "Unkown package type: $($codePlatformInfo.Extension)" + } + } + + $codeExePath = $codePlatformInfo.ExePath + + # Install any extensions + $extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions + foreach ($extension in $extensions) { + Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow + & $codeExePath --install-extension $extension + } + + # Launch if requested + if ($LaunchWhenDone) { + $appName = $codePlatformInfo.AppName + Write-Host "`nInstallation complete, starting $appName...`n`n" -ForegroundColor Green + & $codeExePath + return + } + + Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green } +finally { + $ProgressPreference = $prevProgressPreference +} \ No newline at end of file From 0abacf6c819663190f0a2830a20fde8c8e1697d5 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 31 Oct 2018 19:48:19 -0700 Subject: [PATCH 02/22] Add WhatIf support to script --- scripts/Install-VSCode.ps1 | 43 +++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index bbae1f9d0e..1afbbcac68 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -434,29 +434,47 @@ try switch ($codePlatformInfo.Extension) { # On Debian-like Linux distros 'deb' { + if ($WhatIfPreference) { + Write-Host "WhatIf: apt install $installerPath" + break + } apt install $installerPath break } # On RedHat-list Linux distros 'rpm' { + if ($WhatIfPreference) { + Write-Host "WhatIf: rpm -ivh $installerPath" + break + } rpm -ivh $installerPath break } # On Windows 'exe' { + $exeArgs = '/verysilent /tasks=addtopath' if ($EnableContextMenus) { - Start-Process -Wait $installerPath -ArgumentList "/verysilent /tasks=addcontextmenufiles,addcontextmenufolders,addtopath" + $exeArgs = '/verysilent /tasks=addcontextmenufiles,addcontextmenufolders,addtopath' + } + + if ($WhatIfPreference) { + Write-Host "WhatIf: Running $installerPath with args '$exeArgs'" break } - Start-Process -Wait $installerPath -ArgumentList "/verysilent /tasks=addtopath" + Start-Process -Wait $installerPath -ArgumentList $exeArgs break } # On Mac 'zip' { + if ($WhatIfPreference) { + Write-Host "Expanding zip $installerPath and moving to /Applications/" + break + } + $zipDirPath = [System.IO.Path]::Combine($tmpdir, 'VSCode') Expand-Archive -LiteralPath $installerPath -DestinationPath $zipDirPath -Force Move-Item "$zipDirPath/*.app" '/Applications/' @@ -465,6 +483,11 @@ try # Remaining Linux distros using tar - more complicated 'tar.gz' { + if ($WhatIfPreference) { + Write-Host "Expanding tar $installerPath, moving to /opt/ and symlinking" + break + } + Install-VSCodeFromTar -TarPath $installerPath -Insiders:($BuildEdition -ne 'Stable') break } @@ -478,14 +501,24 @@ try # Install any extensions $extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions - foreach ($extension in $extensions) { - Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow - & $codeExePath --install-extension $extension + if ($WhatIfPreference) { + Write-Host ("Installing extensions: " + ($extensions -join ',')) + } + else { + foreach ($extension in $extensions) { + Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow + & $codeExePath --install-extension $extension + } } # Launch if requested if ($LaunchWhenDone) { $appName = $codePlatformInfo.AppName + + if ($WhatIfPreference) { + Write-Host "Launching $appName from $codeExePath" + } + Write-Host "`nInstallation complete, starting $appName...`n`n" -ForegroundColor Green & $codeExePath return From 867b231251b778d80b2bc357a9cfc1d5fd288d18 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 31 Oct 2018 19:50:49 -0700 Subject: [PATCH 03/22] Use consistent brace style --- scripts/Install-VSCode.ps1 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 1afbbcac68..3b6f6216fb 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -142,20 +142,16 @@ param( [switch]$EnableContextMenus ) -function Test-IsOsX64 -{ - if ($PSVersionTable.PSVersion.Major -lt 6) - { +function Test-IsOsX64 { + if ($PSVersionTable.PSVersion.Major -lt 6) { return (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "64-bit" } return [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture]::X64 } -function Get-LinuxReleaseInfo -{ - if (-not (Test-Path '/etc/*-release')) - { +function Get-LinuxReleaseInfo { + if (-not (Test-Path '/etc/*-release')) { return $null } @@ -306,8 +302,7 @@ function Get-CodePlatformInformation { } } - switch ($BuildEdition) - { + switch ($BuildEdition) { 'Stable' { $channel = 'stable' break @@ -407,8 +402,7 @@ function Install-VSCodeFromTar { ln -s "$destDir/code" /usr/bin/code } -try -{ +try { $prevProgressPreference = $ProgressPreference $onWindows = $IsWindows -or $PSVersionTable.PSVersion.Major -lt 6 From 40ad8f8f483d94715694f5ce20cce7313830d95e Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 31 Oct 2018 19:53:56 -0700 Subject: [PATCH 04/22] Support WhatIf properly --- scripts/Install-VSCode.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 3b6f6216fb..552f5fc87c 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -139,7 +139,9 @@ param( [switch]$LaunchWhenDone, - [switch]$EnableContextMenus + [switch]$EnableContextMenus, + + [switch]$WhatIf ) function Test-IsOsX64 { @@ -404,6 +406,10 @@ function Install-VSCodeFromTar { try { $prevProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + + $prevWhatIfPreference = $WhatIfPreference + $WhatIfPreference = $WhatIfPreference -or $WhatIf $onWindows = $IsWindows -or $PSVersionTable.PSVersion.Major -lt 6 @@ -522,4 +528,5 @@ try { } finally { $ProgressPreference = $prevProgressPreference + $WhatIfPreference = $prevWhatIfPreference } \ No newline at end of file From 3f8aca3e75775de01940b12f483bb7a378b3a74f Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 31 Oct 2018 20:03:31 -0700 Subject: [PATCH 05/22] Fix BuildEdition cases --- scripts/Install-VSCode.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 552f5fc87c..de6d2473c6 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -293,11 +293,11 @@ function Get-CodePlatformInformation { $exePath = "$installBase\Microsoft VS Code\bin\code.cmd" } - 'Insiders-System' { + 'Insider-System' { $exePath = "$installBase\Microsoft VS Code Insiders\bin\code-insiders.cmd" } - 'Insiders-User' { + 'Insider-User' { $exePath = "${env:LocalAppData}\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd" } } @@ -310,12 +310,12 @@ function Get-CodePlatformInformation { break } - 'Insiders-System' { + 'Insider-System' { $channel = 'insider' break } - 'Insiders-User' { + 'Insider-User' { $channel = 'insider' $platform += '-user' break @@ -419,6 +419,7 @@ try { # Download the installer $tmpdir = [System.IO.Path]::GetTempPath() + $ext = $codePlatformInfo.Extension $installerName = "vscode-install.$ext" $installerPath = [System.IO.Path]::Combine($tmpdir, $installerName) @@ -427,7 +428,7 @@ try { Save-WithBitsTransfer -FileUri $codePlatformInfo.FileUri -Destination $installerPath -AppName $codePlatformInfo.AppName } else { - Invoke-WebRequest -Uri $FileUri -OutFile $installerPath + Invoke-WebRequest -Uri $codePlatformInfo.FileUri -OutFile $installerPath } # Install VSCode @@ -517,6 +518,7 @@ try { if ($WhatIfPreference) { Write-Host "Launching $appName from $codeExePath" + return } Write-Host "`nInstallation complete, starting $appName...`n`n" -ForegroundColor Green From 629120b67e76008a836e57d498133a0bd297f51b Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 31 Oct 2018 20:11:23 -0700 Subject: [PATCH 06/22] Eliminate unneeded $info variable --- scripts/Install-VSCode.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index de6d2473c6..979f50bfd0 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -322,7 +322,7 @@ function Get-CodePlatformInformation { } } - $info = @{ + return @{ AppName = $appName ExePath = $exePath Platform = $platform @@ -330,8 +330,6 @@ function Get-CodePlatformInformation { FileUri = "https://vscode-update.azurewebsites.net/latest/$platform/$channel" Extension = $ext } - - return $info } function Save-WithBitsTransfer { From fae546f77789c61c4639e87cfa134b19782d8357 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 09:12:48 -0700 Subject: [PATCH 07/22] Address @tylerl0706's feedback, add package manager installation --- scripts/Install-VSCode.ps1 | 65 ++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 979f50bfd0..6ab9eddd11 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -144,7 +144,17 @@ param( [switch]$WhatIf ) -function Test-IsOsX64 { +# Taken from https://code.visualstudio.com/docs/setup/linux#_installation +$script:VSCodeYumRepoEntry = @" +[code] +name=Visual Studio Code +baseurl=https://packages.microsoft.com/yumrepos/vscode +enabled=1 +gpgcheck=1 +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" } @@ -152,14 +162,19 @@ function Test-IsOsX64 { return [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture]::X64 } -function Get-LinuxReleaseInfo { - if (-not (Test-Path '/etc/*-release')) { - return $null +function Get-AvailablePackageManager +{ + if (Get-Command 'apt' -ErrorAction SilentlyContinue) { + return 'apt' } - return Get-Content -Raw '/etc/*-release' -ErrorAction SilentlyContinue ` - | ConvertFrom-Csv -Delimiter '=' -Header 'Key','Value' ` - | ForEach-Object { $obj = @{} } { $obj[$_.Key] = $_.Value } { [pscustomobject]$obj } + if (Get-Command 'dnf' -ErrorAction SilentlyContinue) { + return 'dnf' + } + + if (Get-Command 'yum' -ErrorAction SilentlyContinue) { + return 'yum' + } } function Get-CodePlatformInformation { @@ -215,18 +230,18 @@ function Get-CodePlatformInformation { switch ($os) { 'Linux' { - $releaseInfo = Get-LinuxReleaseInfo + $pacMan = Get-AvailablePackageManager - switch ($releaseInfo.NAME) { - { 'Ubuntu','Debian' -contains $_ } { + switch ($pacMan) { + 'apt' { $platform = 'linux-deb-x64' $ext = 'deb' break } - { 'Fedora','CentOS','RedHat' -contains $_ } { + { 'dnf','yum' -contains $_ } { $platform = 'linux-rpm-x64' - $ext = 'deb' + $ext = 'rpm' break } @@ -265,7 +280,7 @@ function Get-CodePlatformInformation { '32-bit' { $platform = 'win32' - if (Test-IsOsX64) { + if (Test-IsOsArchX64) { $installBase = ${env:ProgramFiles(x86)} break } @@ -322,7 +337,7 @@ function Get-CodePlatformInformation { } } - return @{ + $info = @{ AppName = $appName ExePath = $exePath Platform = $platform @@ -330,6 +345,12 @@ function Get-CodePlatformInformation { FileUri = "https://vscode-update.azurewebsites.net/latest/$platform/$channel" Extension = $ext } + + if ($pacMan) { + $info['PackageManager'] = $pacMan + } + + return $info } function Save-WithBitsTransfer { @@ -437,17 +458,27 @@ try { Write-Host "WhatIf: apt install $installerPath" break } + + # The deb file contains the information to install its own repository, + # so we just need to install it apt install $installerPath break } # On RedHat-list Linux distros 'rpm' { + $pacMan = $codePlatformInfo.PackageManager if ($WhatIfPreference) { - Write-Host "WhatIf: rpm -ivh $installerPath" + Write-Host "WhatIf: $pacMan install $installerPath" break } - rpm -ivh $installerPath + + # Install the VSCode repo with the package manager + rpm --import https://packages.microsoft.com/keys/microsoft.asc + $script:VSCodeYumRepoEntry > /etc/yum.repos.d/vscode.repo + + # Use dnf or yum depending on the detected package manager + & $pacMan install $installerPath break } @@ -529,4 +560,4 @@ try { finally { $ProgressPreference = $prevProgressPreference $WhatIfPreference = $prevWhatIfPreference -} \ No newline at end of file +} From cb5273995c0cbbf719d436243a5dc14636bd60b8 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 09:15:03 -0700 Subject: [PATCH 08/22] Add SUSE support --- scripts/Install-VSCode.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 6ab9eddd11..b9f25d8bc1 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -175,6 +175,10 @@ function Get-AvailablePackageManager if (Get-Command 'yum' -ErrorAction SilentlyContinue) { return 'yum' } + + if (Get-Command 'zypper' -ErrorAction SilentlyContinue) { + return 'zypper' + } } function Get-CodePlatformInformation { @@ -239,7 +243,7 @@ function Get-CodePlatformInformation { break } - { 'dnf','yum' -contains $_ } { + { 'dnf','yum','zypper' -contains $_ } { $platform = 'linux-rpm-x64' $ext = 'rpm' break From 56a033b84d06d1bc066609215dab175497024f2f Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 10:13:35 -0700 Subject: [PATCH 09/22] Optimize RPM installations --- scripts/Install-VSCode.ps1 | 41 +++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index b9f25d8bc1..841ec2eab9 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -154,6 +154,16 @@ gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc "@ +$script:VSCodeZypperRepoEntry = @" +[code] +name=Visual Studio Code +baseurl=https://packages.microsoft.com/yumrepos/vscode +enabled=1 +type=rpm-md +gpgcheck=1 +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" @@ -450,7 +460,8 @@ try { if ($onWindows) { Save-WithBitsTransfer -FileUri $codePlatformInfo.FileUri -Destination $installerPath -AppName $codePlatformInfo.AppName } - else { + # We don't want to use RPM packages -- see the installation step below + elseif ($codePlatformInfo.Extension -ne 'rpm') { Invoke-WebRequest -Uri $codePlatformInfo.FileUri -OutFile $installerPath } @@ -469,7 +480,9 @@ try { break } - # On RedHat-list Linux distros + # On distros using rpm packages, the RPM package doesn't set up the repo. + # To install VSCode properly in way that the package manager tracks it, + # we have to do things the hard way - install the repo and install the package 'rpm' { $pacMan = $codePlatformInfo.PackageManager if ($WhatIfPreference) { @@ -479,10 +492,28 @@ try { # Install the VSCode repo with the package manager rpm --import https://packages.microsoft.com/keys/microsoft.asc - $script:VSCodeYumRepoEntry > /etc/yum.repos.d/vscode.repo - # Use dnf or yum depending on the detected package manager - & $pacMan install $installerPath + switch ($pacMan) { + 'zypper' { + $script:VSCodeZypperRepoEntry > /etc/zypp/repos.d/vscode.repo + zypper refresh + } + + default { + $script:VSCodeYumRepoEntry > /etc/yum.repos.d/vscode.repo + & $pacMan check-update + } + } + + switch ($BuildEdition) { + 'Stable' { + & $pacMan install code + } + + default { + & $pacMan install code-insiders + } + } break } From f065f06546f06da725ba043dc62fdfedb1a1e3ac Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 11:12:01 -0700 Subject: [PATCH 10/22] Install extensions as user on *nix --- scripts/Install-VSCode.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 841ec2eab9..ca5a78925f 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -437,6 +437,13 @@ function Install-VSCodeFromTar { ln -s "$destDir/code" /usr/bin/code } +# We need to be running as elevated on *nix +if ($IsLinux -or $IsMacOS) { + if ((id -u) -ne 0) { + throw "Must be running as root to install VSCode" + } +} + try { $prevProgressPreference = $ProgressPreference $ProgressPreference = 'SilentlyContinue' @@ -569,6 +576,11 @@ try { if ($WhatIfPreference) { Write-Host ("Installing extensions: " + ($extensions -join ',')) } + elseif ($IsLinux -or $IsMacOS) { + # On *nix we need to install extensions as the user -- VSCode refuses root + $extsSlashes = $extensions -join '/' + sudo -H -u $env:SUDO_USER pwsh -c "`$exts = $extsSlashes -split '/'; foreach (`$e in `$exts) { $codeExePath --install-extension `$e }" + } else { foreach ($extension in $extensions) { Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow From ede509bc0fb43442cdaa493ad7451eba08e06817 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 11:15:00 -0700 Subject: [PATCH 11/22] Fix string template bug --- 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 ca5a78925f..136b020838 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -579,7 +579,7 @@ try { elseif ($IsLinux -or $IsMacOS) { # On *nix we need to install extensions as the user -- VSCode refuses root $extsSlashes = $extensions -join '/' - sudo -H -u $env:SUDO_USER pwsh -c "`$exts = $extsSlashes -split '/'; foreach (`$e in `$exts) { $codeExePath --install-extension `$e }" + sudo -H -u $env:SUDO_USER pwsh -c "`$exts = '$extsSlashes' -split '/'; foreach (`$e in `$exts) { $codeExePath --install-extension `$e }" } else { foreach ($extension in $extensions) { From 5a5dd9a22f89f525e1616a2099e088af664a3137 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 11:26:13 -0700 Subject: [PATCH 12/22] Improve non-sudo error --- 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 136b020838..2e0b439d31 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -440,7 +440,7 @@ function Install-VSCodeFromTar { # We need to be running as elevated on *nix if ($IsLinux -or $IsMacOS) { if ((id -u) -ne 0) { - throw "Must be running as root to install VSCode" + throw "Must be running as root to install VSCode.`nInvoke this script with (for example):`n`tsudo pwsh -f Install-VSCode.ps1 -BuildEdition Stable" } } From f44d870469e579587e17eb8f389a0ed9d357bd6f Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 11:29:36 -0700 Subject: [PATCH 13/22] Simplify sudo test logic --- scripts/Install-VSCode.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 2e0b439d31..0b055111d3 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -438,10 +438,8 @@ function Install-VSCodeFromTar { } # We need to be running as elevated on *nix -if ($IsLinux -or $IsMacOS) { - if ((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" - } +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" } try { From 72191280b19a40fdf0f6a8addb25099ae4ced552 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 11:33:09 -0700 Subject: [PATCH 14/22] Increment script version --- 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 0b055111d3..577c952cd9 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -1,6 +1,6 @@ <#PSScriptInfo -.VERSION 1.2 +.VERSION 1.3 .GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0 From 9cb28564b6283f9701842b3c7c8b795b884a3c2d Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 16:14:59 -0700 Subject: [PATCH 15/22] Add -y to package manager invocations --- scripts/Install-VSCode.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 577c952cd9..8e34f81818 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -481,7 +481,7 @@ try { # The deb file contains the information to install its own repository, # so we just need to install it - apt install $installerPath + apt install -y $installerPath break } @@ -501,22 +501,22 @@ try { switch ($pacMan) { 'zypper' { $script:VSCodeZypperRepoEntry > /etc/zypp/repos.d/vscode.repo - zypper refresh + zypper refresh -y } default { $script:VSCodeYumRepoEntry > /etc/yum.repos.d/vscode.repo - & $pacMan check-update + & $pacMan check-update -y } } switch ($BuildEdition) { 'Stable' { - & $pacMan install code + & $pacMan install -y code } default { - & $pacMan install code-insiders + & $pacMan install -y code-insiders } } break From 5a429aff4bb212c003834478cf2a740b57af7f3a Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 21:39:15 -0700 Subject: [PATCH 16/22] Fix Windows IsOsX64 call --- 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 8e34f81818..329c2f1c32 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -306,7 +306,7 @@ function Get-CodePlatformInformation { '64-bit' { $installBase = ${env:ProgramFiles} - if (Test-IsOsX64) { + if (Test-IsOsArchX64) { $platform = 'win32-x64' break } From 4936994291fa39d93f29bf1b2670aaf2d06a49f0 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 1 Nov 2018 21:58:49 -0700 Subject: [PATCH 17/22] Only use Start-BitsTransfer in Windows PowerShell --- scripts/Install-VSCode.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 329c2f1c32..3429a1b2e3 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -449,8 +449,6 @@ try { $prevWhatIfPreference = $WhatIfPreference $WhatIfPreference = $WhatIfPreference -or $WhatIf - $onWindows = $IsWindows -or $PSVersionTable.PSVersion.Major -lt 6 - # Get information required for installation $codePlatformInfo = Get-CodePlatformInformation -Bitness $Architecture -BuildEdition $BuildEdition @@ -462,7 +460,7 @@ try { $installerPath = [System.IO.Path]::Combine($tmpdir, $installerName) - if ($onWindows) { + if ($PSVersionTable.PSVersion.Major -lt 6) { Save-WithBitsTransfer -FileUri $codePlatformInfo.FileUri -Destination $installerPath -AppName $codePlatformInfo.AppName } # We don't want to use RPM packages -- see the installation step below From 641aa43f771509836d8d47b612b147b6576b9fb1 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 5 Nov 2018 10:54:10 -0800 Subject: [PATCH 18/22] Correct usage of WhatIf --- scripts/Install-VSCode.ps1 | 49 ++++++++++++++------------------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 3429a1b2e3..bde261b7c4 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -123,7 +123,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #> -[CmdletBinding()] +[CmdletBinding(SupportsShouldProcess=$true)] param( [parameter()] [ValidateSet(, "64-bit", "32-bit")] @@ -140,8 +140,6 @@ param( [switch]$LaunchWhenDone, [switch]$EnableContextMenus, - - [switch]$WhatIf ) # Taken from https://code.visualstudio.com/docs/setup/linux#_installation @@ -446,9 +444,6 @@ try { $prevProgressPreference = $ProgressPreference $ProgressPreference = 'SilentlyContinue' - $prevWhatIfPreference = $WhatIfPreference - $WhatIfPreference = $WhatIfPreference -or $WhatIf - # Get information required for installation $codePlatformInfo = Get-CodePlatformInformation -Bitness $Architecture -BuildEdition $BuildEdition @@ -472,8 +467,7 @@ try { switch ($codePlatformInfo.Extension) { # On Debian-like Linux distros 'deb' { - if ($WhatIfPreference) { - Write-Host "WhatIf: apt install $installerPath" + if (-not $PSCmdlet.ShouldProcess($installerPath, 'apt install -y')) { break } @@ -488,8 +482,7 @@ try { # we have to do things the hard way - install the repo and install the package 'rpm' { $pacMan = $codePlatformInfo.PackageManager - if ($WhatIfPreference) { - Write-Host "WhatIf: $pacMan install $installerPath" + if (-not $PSCmdlet.ShouldProcess($installerPath, "$pacMan install -y")) { break } @@ -527,8 +520,7 @@ try { $exeArgs = '/verysilent /tasks=addcontextmenufiles,addcontextmenufolders,addtopath' } - if ($WhatIfPreference) { - Write-Host "WhatIf: Running $installerPath with args '$exeArgs'" + if (-not $PSCmdlet.ShouldProcess("$installerPath $exeArgs", 'Start-Process -Wait')) { break } @@ -538,8 +530,7 @@ try { # On Mac 'zip' { - if ($WhatIfPreference) { - Write-Host "Expanding zip $installerPath and moving to /Applications/" + if (-not $PSCmdlet.ShouldProcess($installerPath, "Expand-Archive -DestinationPath $zipDirPath -Force; Move-Item $zipDirPath/*.app /Applications/")) { break } @@ -551,8 +542,7 @@ try { # Remaining Linux distros using tar - more complicated 'tar.gz' { - if ($WhatIfPreference) { - Write-Host "Expanding tar $installerPath, moving to /opt/ and symlinking" + if (-not $PSCmdlet.ShouldProcess($installerPath, 'Install-VSCodeFromTar (expand, move to /opt/, symlink)')) { break } @@ -569,18 +559,17 @@ try { # Install any extensions $extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions - if ($WhatIfPreference) { - Write-Host ("Installing extensions: " + ($extensions -join ',')) - } - elseif ($IsLinux -or $IsMacOS) { - # On *nix we need to install extensions as the user -- VSCode refuses root - $extsSlashes = $extensions -join '/' - sudo -H -u $env:SUDO_USER pwsh -c "`$exts = '$extsSlashes' -split '/'; foreach (`$e in `$exts) { $codeExePath --install-extension `$e }" - } - else { - foreach ($extension in $extensions) { - Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow - & $codeExePath --install-extension $extension + if ($PSCmdlet.ShouldProcess(($extensions -join ','), "$codeExePath --install-extension")) { + if ($IsLinux -or $IsMacOS) { + # On *nix we need to install extensions as the user -- VSCode refuses root + $extsSlashes = $extensions -join '/' + sudo -H -u $env:SUDO_USER pwsh -c "`$exts = '$extsSlashes' -split '/'; foreach (`$e in `$exts) { $codeExePath --install-extension `$e }" + } + else { + foreach ($extension in $extensions) { + Write-Host "`nInstalling extension $extension..." -ForegroundColor Yellow + & $codeExePath --install-extension $extension + } } } @@ -588,8 +577,7 @@ try { if ($LaunchWhenDone) { $appName = $codePlatformInfo.AppName - if ($WhatIfPreference) { - Write-Host "Launching $appName from $codeExePath" + if (-not $PSCmdlet.ShouldProcess($appName, "Launch with $codeExePath")) { return } @@ -602,5 +590,4 @@ try { } finally { $ProgressPreference = $prevProgressPreference - $WhatIfPreference = $prevWhatIfPreference } From 1dc7b182fb8865e0a321c4565bc8bb1db47a7070 Mon Sep 17 00:00:00 2001 From: Patrick Meinecke Date: Wed, 7 Nov 2018 10:42:19 -0800 Subject: [PATCH 19/22] Update scripts/Install-VSCode.ps1 Co-Authored-By: rjmholt --- 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 bde261b7c4..186284cf45 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -139,7 +139,7 @@ param( [switch]$LaunchWhenDone, - [switch]$EnableContextMenus, + [switch]$EnableContextMenus ) # Taken from https://code.visualstudio.com/docs/setup/linux#_installation From 5ac4579d59d45f9515dfb58cdba7b84fa24d57f3 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 7 Nov 2018 10:54:19 -0800 Subject: [PATCH 20/22] Improve WhatIf usage --- scripts/Install-VSCode.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/Install-VSCode.ps1 b/scripts/Install-VSCode.ps1 index 186284cf45..5290192e39 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -455,12 +455,14 @@ try { $installerPath = [System.IO.Path]::Combine($tmpdir, $installerName) - if ($PSVersionTable.PSVersion.Major -lt 6) { + if ($PSVersionTable.PSVersion.Major -le 5) { Save-WithBitsTransfer -FileUri $codePlatformInfo.FileUri -Destination $installerPath -AppName $codePlatformInfo.AppName } # We don't want to use RPM packages -- see the installation step below elseif ($codePlatformInfo.Extension -ne 'rpm') { - Invoke-WebRequest -Uri $codePlatformInfo.FileUri -OutFile $installerPath + if ($PSCmdlet.ShouldProcess($codePlatformInfo.FileUri, "Invoke-WebRequest -OutFile $installerPath") { + Invoke-WebRequest -Uri $codePlatformInfo.FileUri -OutFile $installerPath + } } # Install VSCode @@ -586,7 +588,9 @@ try { return } - Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green + if ($PSCmdlet.ShouldProcess('Installation complete!', 'Write-Host') { + Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green + } } finally { $ProgressPreference = $prevProgressPreference From e7859d6e24106c907c1664c2b0439b54126d4a2b Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 7 Nov 2018 10:57:17 -0800 Subject: [PATCH 21/22] Fix paren error --- 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 5290192e39..c69acab375 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -460,7 +460,7 @@ try { } # We don't want to use RPM packages -- see the installation step below elseif ($codePlatformInfo.Extension -ne 'rpm') { - if ($PSCmdlet.ShouldProcess($codePlatformInfo.FileUri, "Invoke-WebRequest -OutFile $installerPath") { + if ($PSCmdlet.ShouldProcess($codePlatformInfo.FileUri, "Invoke-WebRequest -OutFile $installerPath")) { Invoke-WebRequest -Uri $codePlatformInfo.FileUri -OutFile $installerPath } } From 3a1ddf413280890e97c82e8a1bf6eba3f67a5a06 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 7 Nov 2018 10:58:54 -0800 Subject: [PATCH 22/22] Fix paren error --- 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 c69acab375..28da33c1fe 100644 --- a/scripts/Install-VSCode.ps1 +++ b/scripts/Install-VSCode.ps1 @@ -588,7 +588,7 @@ try { return } - if ($PSCmdlet.ShouldProcess('Installation complete!', 'Write-Host') { + if ($PSCmdlet.ShouldProcess('Installation complete!', 'Write-Host')) { Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green } }