Skip to content

Commit

Permalink
use powershell.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt committed Apr 21, 2020
1 parent bbd1963 commit 6fe3e48
Showing 1 changed file with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,29 @@ private async Task CheckPackageManagement()
// If the user chose "Not now" ignore it for the rest of the session.
if (messageAction?.Title == takeActionText)
{
// Update PackageManagement
PSCommand psCommand = new PSCommand()
.AddCommand("Install-Module")
.AddParameter("Name", "PackageManagement")
.AddParameter("Force")
.AddParameter("MinimumVersion", s_desiredPackageManagementVersion)
.AddParameter("Scope", "CurrentUser")
.AddParameter("AllowClobber");

StringBuilder errors = new StringBuilder();
await _powerShellContextService.ExecuteCommandAsync<object>(psCommand, errors, new ExecutionOptions
{
WriteInputToHost = true,
WriteErrorsToHost = true,
WriteOutputToHost = true,
InputString = "Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber"
}).ConfigureAwait(false);
await _powerShellContextService.ExecuteScriptStringAsync(
"powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'",
errors,
writeInputToHost: true,
writeOutputToHost: true,
addToHistory: true).ConfigureAwait(false);

// There were errors installing PackageManagement.
if (errors.Length == 0)
{
_languageServer.Window.ShowMessage(new ShowMessageParams
{
Type = MessageType.Warning,
Message = "PackageManagement updated, please restart the PowerShell extension."
Type = MessageType.Info,
Message = "PackageManagement updated, If you already had PackageManagement loaded in your session, please restart the PowerShell extension."
});
}
else
{
_languageServer.Window.ShowMessage(new ShowMessageParams
{
Type = MessageType.Error,
Message = "PackageManagement update failed. Please run the following command in a Windows PowerShell prompt and restart the PowerShell extension: `Install-Module PackageManagement -Force -AllowClobber`"
Message = "PackageManagement update failed. Please run the following command in a Windows PowerShell prompt and restart the PowerShell extension: `Install-Module PackageManagement -Force -AllowClobber -MinimumVersion 1.4.6`"
});
}
}
Expand Down

0 comments on commit 6fe3e48

Please sign in to comment.