Skip to content

Add setting to enable use of Windows PowerShell developer builds #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@
"default": "",
"description": "Specifies the full path to a PowerShell executable. Used to change the installation of PowerShell used for language and debugging services."
},
"powershell.developer.powerShellExeIsWindowsDevBuild": {
"type": "boolean",
"default": false,
"description": "If true, indicates that the powerShellExePath points to a developer build of Windows PowerShell and should be configured appropriately."
},
"powershell.developer.bundledModulesPath": {
"type": "string",
"default": "../modules/",
Expand Down
28 changes: 23 additions & 5 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface CurrentSessionConfiguration {
interface PathSessionConfiguration {
type: SessionType.UsePath,
path: string;
isWindowsDevBuild: boolean;
}

interface BuiltInSessionConfiguration {
Expand Down Expand Up @@ -118,8 +119,13 @@ export class SessionManager {
startArgs += "-LogLevel '" + this.sessionSettings.developer.editorServicesLogLevel + "' "
}

var isWindowsDevBuild =
this.sessionConfiguration.type == SessionType.UsePath
? this.sessionConfiguration.isWindowsDevBuild : false;

this.startPowerShell(
this.sessionConfiguration.path,
isWindowsDevBuild,
bundledModulesPath,
startArgs);
}
Expand Down Expand Up @@ -214,7 +220,11 @@ export class SessionManager {
]
}

private startPowerShell(powerShellExePath: string, bundledModulesPath: string, startArgs: string) {
private startPowerShell(
powerShellExePath: string,
isWindowsDevBuild: boolean,
bundledModulesPath: string,
startArgs: string) {
try
{
this.setSessionStatus(
Expand Down Expand Up @@ -242,10 +252,14 @@ export class SessionManager {

powerShellArgs.push(
"-Command",
"& '" + startScriptPath + "' " + startArgs)
"& '" + startScriptPath + "' " + startArgs);

// Launch PowerShell as child process
this.powerShellProcess = cp.spawn(powerShellExePath, powerShellArgs);
this.powerShellProcess =
cp.spawn(
powerShellExePath,
powerShellArgs,
{ env: isWindowsDevBuild ? { "DEVPATH": path.dirname(powerShellExePath) } : {} });

var decoder = new StringDecoder('utf8');
this.powerShellProcess.stdout.on(
Expand Down Expand Up @@ -466,7 +480,9 @@ export class SessionManager {
var powerShellExePath = (this.sessionSettings.developer.powerShellExePath || "").trim();
if (powerShellExePath.length > 0) {
return this.resolveSessionConfiguration(
{ type: SessionType.UsePath, path: this.sessionSettings.developer.powerShellExePath});
{ type: SessionType.UsePath,
path: this.sessionSettings.developer.powerShellExePath,
isWindowsDevBuild: this.sessionSettings.developer.powerShellExeIsWindowsDevBuild});
}
else {
return this.resolveSessionConfiguration(
Expand Down Expand Up @@ -591,7 +607,9 @@ export class SessionManager {
`Switch to PowerShell at path: ${this.sessionSettings.developer.powerShellExePath}`,
() => {
this.restartSession(
{ type: SessionType.UsePath, path: this.sessionSettings.developer.powerShellExePath })
{ type: SessionType.UsePath,
path: this.sessionSettings.developer.powerShellExePath,
isWindowsDevBuild: this.sessionSettings.developer.powerShellExeIsWindowsDevBuild })
}));
}

Expand Down
4 changes: 3 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface IDeveloperSettings {
bundledModulesPath?: string;
editorServicesLogLevel?: string;
editorServicesWaitForDebugger?: boolean;
powerShellExeIsWindowsDevBuild?: boolean;
}

export interface ISettings {
Expand All @@ -43,7 +44,8 @@ export function load(myPluginId: string): ISettings {
powerShellExePath: undefined,
bundledModulesPath: "../modules/",
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false
editorServicesWaitForDebugger: false,
powerShellExeIsWindowsDevBuild: false
};

let defaultCodeFormattingSettings: ICodeFormattingSettings = {
Expand Down