Skip to content

Commit c11651e

Browse files
committed
Add setting to enable use of Windows PowerShell developer builds
This change adds a new setting called "powershell.developer.powerShellExeIsWindowsDevBuild" which identifies that the specified powerShellExePath refers to a developer build of Windows PowerShell. This is needed because an environment variable needs to be set before using such a build with the PowerShell extension.
1 parent 393cd76 commit c11651e

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@
316316
"default": "",
317317
"description": "Specifies the full path to a PowerShell executable. Used to change the installation of PowerShell used for language and debugging services."
318318
},
319+
"powershell.developer.powerShellExeIsWindowsDevBuild": {
320+
"type": "boolean",
321+
"default": false,
322+
"description": "If true, indicates that the powerShellExePath points to a developer build of Windows PowerShell and should be configured appropriately."
323+
},
319324
"powershell.developer.bundledModulesPath": {
320325
"type": "string",
321326
"default": "../modules/",

src/session.ts

+23-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface CurrentSessionConfiguration {
4242
interface PathSessionConfiguration {
4343
type: SessionType.UsePath,
4444
path: string;
45+
isWindowsDevBuild: boolean;
4546
}
4647

4748
interface BuiltInSessionConfiguration {
@@ -118,8 +119,13 @@ export class SessionManager {
118119
startArgs += "-LogLevel '" + this.sessionSettings.developer.editorServicesLogLevel + "' "
119120
}
120121

122+
var isWindowsDevBuild =
123+
this.sessionConfiguration.type == SessionType.UsePath
124+
? this.sessionConfiguration.isWindowsDevBuild : false;
125+
121126
this.startPowerShell(
122127
this.sessionConfiguration.path,
128+
isWindowsDevBuild,
123129
bundledModulesPath,
124130
startArgs);
125131
}
@@ -214,7 +220,11 @@ export class SessionManager {
214220
]
215221
}
216222

217-
private startPowerShell(powerShellExePath: string, bundledModulesPath: string, startArgs: string) {
223+
private startPowerShell(
224+
powerShellExePath: string,
225+
isWindowsDevBuild: boolean,
226+
bundledModulesPath: string,
227+
startArgs: string) {
218228
try
219229
{
220230
this.setSessionStatus(
@@ -242,10 +252,14 @@ export class SessionManager {
242252

243253
powerShellArgs.push(
244254
"-Command",
245-
"& '" + startScriptPath + "' " + startArgs)
255+
"& '" + startScriptPath + "' " + startArgs);
246256

247257
// Launch PowerShell as child process
248-
this.powerShellProcess = cp.spawn(powerShellExePath, powerShellArgs);
258+
this.powerShellProcess =
259+
cp.spawn(
260+
powerShellExePath,
261+
powerShellArgs,
262+
{ env: isWindowsDevBuild ? { "DEVPATH": path.dirname(powerShellExePath) } : {} });
249263

250264
var decoder = new StringDecoder('utf8');
251265
this.powerShellProcess.stdout.on(
@@ -466,7 +480,9 @@ export class SessionManager {
466480
var powerShellExePath = (this.sessionSettings.developer.powerShellExePath || "").trim();
467481
if (powerShellExePath.length > 0) {
468482
return this.resolveSessionConfiguration(
469-
{ type: SessionType.UsePath, path: this.sessionSettings.developer.powerShellExePath});
483+
{ type: SessionType.UsePath,
484+
path: this.sessionSettings.developer.powerShellExePath,
485+
isWindowsDevBuild: this.sessionSettings.developer.powerShellExeIsWindowsDevBuild});
470486
}
471487
else {
472488
return this.resolveSessionConfiguration(
@@ -591,7 +607,9 @@ export class SessionManager {
591607
`Switch to PowerShell at path: ${this.sessionSettings.developer.powerShellExePath}`,
592608
() => {
593609
this.restartSession(
594-
{ type: SessionType.UsePath, path: this.sessionSettings.developer.powerShellExePath })
610+
{ type: SessionType.UsePath,
611+
path: this.sessionSettings.developer.powerShellExePath,
612+
isWindowsDevBuild: this.sessionSettings.developer.powerShellExeIsWindowsDevBuild })
595613
}));
596614
}
597615

src/settings.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface IDeveloperSettings {
2121
bundledModulesPath?: string;
2222
editorServicesLogLevel?: string;
2323
editorServicesWaitForDebugger?: boolean;
24+
powerShellExeIsWindowsDevBuild?: boolean;
2425
}
2526

2627
export interface ISettings {
@@ -43,7 +44,8 @@ export function load(myPluginId: string): ISettings {
4344
powerShellExePath: undefined,
4445
bundledModulesPath: "../modules/",
4546
editorServicesLogLevel: "Normal",
46-
editorServicesWaitForDebugger: false
47+
editorServicesWaitForDebugger: false,
48+
powerShellExeIsWindowsDevBuild: false
4749
};
4850

4951
let defaultCodeFormattingSettings: ICodeFormattingSettings = {

0 commit comments

Comments
 (0)