Skip to content

Commit 86b7fe5

Browse files
committed
Suppress startup banner for dotnet global install of PowerShell
1 parent 75e2460 commit 86b7fe5

File tree

4 files changed

+171
-11
lines changed

4 files changed

+171
-11
lines changed

src/platform.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface IPlatformDetails {
3838
export interface IPowerShellExeDetails {
3939
readonly displayName: string;
4040
readonly exePath: string;
41+
readonly supportsProperArguments: boolean;
4142
}
4243

4344
export function getPlatformDetails(): IPlatformDetails {
@@ -266,6 +267,7 @@ export class PowerShellExeFinder {
266267

267268
const dotnetGlobalToolExePath: string = path.join(os.homedir(), ".dotnet", "tools", exeName);
268269

270+
// The dotnet installed version of PowerShell does not support proper argument parsing, and so it fails with our multi-line startup banner.
269271
return new PossiblePowerShellExe(dotnetGlobalToolExePath, ".NET Core PowerShell Global Tool", undefined, false);
270272
}
271273

src/process.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import vscode = require("vscode");
99
import { Logger } from "./logging";
1010
import Settings = require("./settings");
1111
import utils = require("./utils");
12-
import { IEditorServicesSessionDetails, SessionManager } from "./session";
12+
import { IEditorServicesSessionDetails } from "./session";
1313

1414
export class PowerShellProcess {
1515
public static escapeSingleQuotes(psPath: string): string {
@@ -83,12 +83,14 @@ export class PowerShellProcess {
8383
PowerShellProcess.escapeSingleQuotes(psesModulePath) +
8484
"'; Start-EditorServices " + this.startPsesArgs;
8585

86+
// On Windows we unfortunately can't Base64 encode the startup command
87+
// because it annoys some poorly implemented anti-virus scanners.
8688
if (utils.isWindows) {
8789
powerShellArgs.push(
8890
"-Command",
8991
startEditorServices);
9092
} else {
91-
// Use -EncodedCommand for better quote support on non-Windows
93+
// Otherwise use -EncodedCommand for better quote support.
9294
powerShellArgs.push(
9395
"-EncodedCommand",
9496
Buffer.from(startEditorServices, "utf16le").toString("base64"));

src/session.ts

+7
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ export class SessionManager implements Middleware {
215215

216216
if (this.sessionSettings.integratedConsole.suppressStartupBanner) {
217217
this.editorServicesArgs += "-StartupBanner '' ";
218+
} else if (utils.isWindows && !this.PowerShellExeDetails.supportsProperArguments) {
219+
// NOTE: On Windows we don't Base64 encode the startup command
220+
// because it annoys some poorly implemented anti-virus scanners.
221+
// Unfortunately this means that for some installs of PowerShell
222+
// (such as through the `dotnet` package manager), we can't include
223+
// a multi-line startup banner as the quotes break the command.
224+
this.editorServicesArgs += `-StartupBanner '${this.HostName} Extension v${this.HostVersion}' `;
218225
} else {
219226
const startupBanner = `${this.HostName} Extension v${this.HostVersion}
220227
Copyright (c) Microsoft Corporation.

0 commit comments

Comments
 (0)