diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs index e055380d1..47b397400 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs @@ -87,7 +87,13 @@ private async Task CheckPackageManagement() break; } - _logger.LogDebug("Old version of PackageManagement detected. Attempting to update."); + _logger.LogDebug("Old version of PackageManagement detected."); + + if (_powerShellContextService.CurrentRunspace.Runspace.SessionStateProxy.LanguageMode != PSLanguageMode.FullLanguage) + { + _languageServer.Window.ShowWarning("You have an older version of PackageManagement known to cause issues with the PowerShell extension. 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`"); + return; + } var takeActionText = "Yes"; MessageActionItem messageAction = await _languageServer.Window.ShowMessage(new ShowMessageRequestParams @@ -120,6 +126,7 @@ await _powerShellContextService.ExecuteScriptStringAsync( if (errors.Length == 0) { + _logger.LogDebug("PackageManagement is updated."); _languageServer.Window.ShowMessage(new ShowMessageParams { Type = MessageType.Info, @@ -129,6 +136,7 @@ await _powerShellContextService.ExecuteScriptStringAsync( else { // There were errors installing PackageManagement. + _logger.LogError($"PackageManagement installation had errors: {errors.ToString()}"); _languageServer.Window.ShowMessage(new ShowMessageParams { Type = MessageType.Error,