Skip to content

Commit

Permalink
Merge pull request #1670 from paulvanbrenk/debugArguments
Browse files Browse the repository at this point in the history
Actually use project arguments when debugging
  • Loading branch information
paulvanbrenk authored Aug 24, 2017
2 parents cf7f764 + 59eb4a3 commit 70594ab
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)),
Expand All @@ -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<string>();
}

private void LaunchDebugger(IServiceProvider provider, VsDebugTargetInfo dbgInfo)
Expand Down

0 comments on commit 70594ab

Please sign in to comment.