From e5d08c43ae8ac9699d2eb69dd8cd1a9b22209394 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 12 Feb 2020 16:19:39 -0800 Subject: [PATCH] Close other pwsh's in the VSCode instance --- .vscode/tasks.json | 2 +- src/features/UpdatePowerShell.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 647e9e534b..c4f6a47392 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ "windows": { "options": { "shell": { - "executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "executable": "pwsh.exe", "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ] } } diff --git a/src/features/UpdatePowerShell.ts b/src/features/UpdatePowerShell.ts index ba33673063..d20fa1fb66 100644 --- a/src/features/UpdatePowerShell.ts +++ b/src/features/UpdatePowerShell.ts @@ -116,7 +116,8 @@ export async function InvokePowerShellUpdateCheck( const result = await window.showInformationMessage( `${commonText} Would you like to update the version? ${ - isMacOS ? "(Homebrew is required on macOS)" : "" + isMacOS ? "(Homebrew is required on macOS)" + : "(This will close ALL pwsh terminals running in this Visual Studio Code session)" }`, ...options); // If the user cancels the notification. @@ -151,6 +152,15 @@ export async function InvokePowerShellUpdateCheck( // Stop the Integrated Console session because Windows likes to hold on to files. sessionManager.stop(); + // Close all terminals with the name "pwsh" in the current VS Code session. + // This will encourage folks to not close the instance of VS Code that spawned + // the MSI process. + for (const terminal of window.terminals) { + if (terminal.name === "pwsh") { + terminal.dispose(); + } + } + // Invoke the MSI via cmd. const msi = spawn("msiexec", ["/i", msiDownloadPath]);