diff --git a/Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs b/Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs index cdd2559bc..9307d20f0 100644 --- a/Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs +++ b/Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; @@ -407,13 +407,18 @@ private void StartWithChromeV2Debugger(string file, string nodePath, bool startB var webBrowserUrl = GetFullUrl(); var envVars = GetEnvironmentVariables(webBrowserUrl); + var runtimeArguments = ConvertArguments(this._project.GetProjectProperty(NodeProjectProperty.NodeExeArguments)); + var scriptArguments = ConvertArguments(this._project.GetProjectProperty(NodeProjectProperty.ScriptArguments)); + var cwd = _project.GetWorkingDirectory(); // Current working directory var configuration = new JObject( new JProperty("name", "Debug Node.js program from Visual Studio"), new JProperty("type", "node2"), new JProperty("request", "launch"), new JProperty("program", file), + new JProperty("args", scriptArguments), new JProperty("runtimeExecutable", nodePath), + new JProperty("runtimeArgs", runtimeArguments), new JProperty("cwd", cwd), new JProperty("console", "externalTerminal"), new JProperty("env", JObject.FromObject(envVars)), @@ -436,30 +441,31 @@ private void StartWithChromeV2Debugger(string file, string nodePath, bool startB var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; - var debugger = serviceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4; + var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger)); debugger.LaunchDebugTargets4(1, debugTargets, processInfo); // Launch browser - if (startBrowser) + if (startBrowser && !string.IsNullOrWhiteSpace(webBrowserUrl)) { - Uri uri = null; - if (!String.IsNullOrWhiteSpace(webBrowserUrl)) - { - uri = new Uri(webBrowserUrl); - } + var uri = new Uri(webBrowserUrl); + OnPortOpenedHandler.CreateHandler( + uri.Port, + shortCircuitPredicate: () => false, + action: () => + { + VsShellUtilities.OpenBrowser(webBrowserUrl, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser); + } + ); + } + } - if (uri != null) - { - OnPortOpenedHandler.CreateHandler( - uri.Port, - shortCircuitPredicate: () => false, - action: () => - { - VsShellUtilities.OpenBrowser(webBrowserUrl, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser); - } - ); - } + private static string[] ConvertArguments(string argumentString) + { + if (argumentString != null) + { + return argumentString.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } + return Array.Empty(); } private void LaunchDebugger(IServiceProvider provider, VsDebugTargetInfo dbgInfo)