From 7975481e9bc01b6b97e776c28f112e3d289a54c6 Mon Sep 17 00:00:00 2001 From: Serkan Zengin Date: Thu, 18 Jun 2020 09:20:01 +0300 Subject: [PATCH] Enhanced package update failure message on line 143 and added Repository option to Install-Module command --- .../PowerShellContext/Handlers/GetVersionHandler.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs index 5cb39c3aa..290a53158 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs @@ -82,7 +82,7 @@ private async Task CheckPackageManagement() foreach (PSModuleInfo module in await _powerShellContextService.ExecuteCommandAsync(getModule)) { // The user has a good enough version of PackageManagement - if(module.Version >= s_desiredPackageManagementVersion) + if (module.Version >= s_desiredPackageManagementVersion) { break; } @@ -100,7 +100,7 @@ private async Task CheckPackageManagement() { Message = "You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?", Type = MessageType.Warning, - Actions = new [] + Actions = new[] { new MessageActionItem { @@ -118,7 +118,7 @@ private async Task CheckPackageManagement() { StringBuilder errors = new StringBuilder(); await _powerShellContextService.ExecuteScriptStringAsync( - "powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'", + "powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber' -Repository PSGallery", errors, writeInputToHost: true, writeOutputToHost: true, @@ -140,7 +140,7 @@ await _powerShellContextService.ExecuteScriptStringAsync( _languageServer.Window.ShowMessage(new ShowMessageParams { Type = MessageType.Error, - Message = "PackageManagement update failed. Please run the following command in a new Windows PowerShell session and then restart the PowerShell extension: `Install-Module PackageManagement -Force -AllowClobber -MinimumVersion 1.4.6`" + Message = "PackageManagement update failed. This might be due to PowerShell Gallery using TLS 1.2. More info can be found at https://aka.ms/psgallerytls" }); } }