Example #1
0
        private void StartAndAttachDebugger(string file, string nodePath, bool startBrowser)
        {
            // start the node process
            var workingDir         = _project.GetWorkingDirectory();
            var url                = GetFullUrl();
            var env                = GetEnvironmentVariablesString(url);
            var interpreterOptions = _project.GetProjectProperty(NodeProjectProperty.NodeExeArguments);
            var debugOptions       = this.GetDebugOptions();
            var script             = GetFullArguments(file, includeNodeArgs: false);

            var process = NodeDebugger.StartNodeProcessWithInspect(exe: nodePath, script: script, dir: workingDir, env: env, interpreterOptions: interpreterOptions, debugOptions: debugOptions);

            process.Start();

            // setup debug info and attach
            var debugUri = $"http://127.0.0.1:{process.DebuggerPort}";

            var dbgInfo = new VsDebugTargetInfo4();

            dbgInfo.dlo         = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
            dbgInfo.LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd;

            dbgInfo.guidLaunchDebugEngine = WebkitDebuggerGuid;
            dbgInfo.dwDebugEngineCount    = 1;

            var enginesPtr = MarshalDebugEngines(new[] { WebkitDebuggerGuid });

            dbgInfo.pDebugEngines       = enginesPtr;
            dbgInfo.guidPortSupplier    = WebkitPortSupplierGuid;
            dbgInfo.bstrPortName        = debugUri;
            dbgInfo.fSendToOutputWindow = 0;

            // we connect through a URI, so no need to set the process,
            // we need to set the process id to '1' so the debugger is able to attach
            dbgInfo.bstrExe = $"\01";

            AttachDebugger(dbgInfo);

            if (startBrowser)
            {
                Uri uri = null;
                if (!String.IsNullOrWhiteSpace(url))
                {
                    uri = new Uri(url);
                }

                if (uri != null)
                {
                    OnPortOpenedHandler.CreateHandler(
                        uri.Port,
                        shortCircuitPredicate: () => process.HasExited,
                        action: () =>
                    {
                        VsShellUtilities.OpenBrowser(url, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser);
                    }
                        );
                }
            }
        }
        public NodejsProjectLauncher(NodejsProjectNode project) {
            _project = project;

            var portNumber = _project.GetProjectProperty(NodeProjectProperty.NodejsPort);
            int portNum;
            if (Int32.TryParse(portNumber, out portNum)) {
                _testServerPort = portNum;
            }
        }
        public NodejsProjectLauncher(NodejsProjectNode project) {
            _project = project;

            var portNumber = _project.GetProjectProperty(NodejsConstants.NodejsPort);
            int portNum;
            if (Int32.TryParse(portNumber, out portNum)) {
                _testServerPort = portNum;
            }
        }
 private string GetFullArguments(string file, bool includeNodeArgs = true) {
     string res = String.Empty;
     if (includeNodeArgs) {
         var nodeArgs = _project.GetProjectProperty(NodejsConstants.NodeExeArguments);
         if (!String.IsNullOrWhiteSpace(nodeArgs)) {
             res = nodeArgs + " ";
         }
     }
     res += "\"" + file + "\"";
     var scriptArgs = _project.GetProjectProperty(NodejsConstants.ScriptArguments);
     if (!String.IsNullOrWhiteSpace(scriptArgs)) {
         res += " " + scriptArgs;
     }
     return res;
 }
        private void StartAndAttachDebugger(string file, string nodePath)
        {
            // start the node process
            var workingDir         = _project.GetWorkingDirectory();
            var url                = GetFullUrl();
            var env                = GetEnvironmentVariablesString(url);
            var interpreterOptions = _project.GetProjectProperty(NodeProjectProperty.NodeExeArguments);
            var debugOptions       = this.GetDebugOptions();
            var script             = GetFullArguments(file, includeNodeArgs: false);

            var process = NodeDebugger.StartNodeProcessWithInspect(exe: nodePath, script: script, dir: workingDir, env: env, interpreterOptions: interpreterOptions, debugOptions: debugOptions);

            process.Start();

            // setup debug info and attach
            var debugUri = $"http://127.0.0.1:{process.DebuggerPort}";

            var dbgInfo = new VsDebugTargetInfo4();

            dbgInfo.dlo         = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
            dbgInfo.LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd;

            dbgInfo.guidLaunchDebugEngine = WebkitDebuggerGuid;
            dbgInfo.dwDebugEngineCount    = 1;

            var enginesPtr = MarshalDebugEngines(new[] { WebkitDebuggerGuid });

            dbgInfo.pDebugEngines       = enginesPtr;
            dbgInfo.guidPortSupplier    = WebkitPortSupplierGuid;
            dbgInfo.bstrPortName        = debugUri;
            dbgInfo.fSendToOutputWindow = 0;

            // we connect through a URI, so no need to set the process,
            // we need to set the process id to '1' so the debugger is able to attach
            dbgInfo.bstrExe = $"\01";

            AttachDebugger(dbgInfo);
        }