private static void RunProfiler(SessionNode session, string interpreter, string interpreterArgs, string script, string scriptArgs, string workingDir, Dictionary<string, string> env, bool openReport, string launchUrl, int? port, bool startBrowser) {
            if (String.IsNullOrWhiteSpace(interpreter)) {
                Nodejs.ShowNodejsNotInstalled();
                return;
            } else if (!File.Exists(interpreter)) {
                Nodejs.ShowNodejsPathNotFound(interpreter);
                return;
            }

            var arch = NativeMethods.GetBinaryType(interpreter);

            bool jmc = true;
            using (var vsperfKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings).OpenSubKey("VSPerf")) {
                if (vsperfKey != null) {
                    var value = vsperfKey.GetValue("tools.options.justmycode");
                    int jmcSetting;
                    if (value != null && value is string && Int32.TryParse((string)value, out jmcSetting)) {
                        jmc = jmcSetting != 0;
                    }
                }
            }

            var process = new ProfiledProcess(interpreter, interpreterArgs, script, scriptArgs, workingDir, env, arch, launchUrl, port, startBrowser, jmc);

            string baseName = Path.GetFileNameWithoutExtension(session.Filename);
            string date = DateTime.Now.ToString("yyyyMMdd");
            string outPath = Path.Combine(Path.GetDirectoryName(session.Filename), baseName + "_" + date + ".vspx");

            int count = 1;
            while (File.Exists(outPath)) {
                outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + "(" + count + ").vspx");
                count++;
            }

            process.ProcessExited += (sender, args) => {
                var dte = (EnvDTE.DTE)NodejsProfilingPackage.GetGlobalService(typeof(EnvDTE.DTE));
                _profilingProcess = null;
                _stopCommand.Enabled = false;
                _startCommand.Enabled = true;
                _startCommandCtx.Enabled = true;
                if (openReport && File.Exists(outPath)) {
                    dte.ItemOperations.OpenFile(outPath);
                }
            };

            session.AddProfile(outPath);

            process.StartProfiling(outPath);
            _profilingProcess = process;
            _stopCommand.Enabled = true;
            _startCommand.Enabled = false;
            _startCommandCtx.Enabled = false;
        }
        private static void RunProfiler(SessionNode session, string interpreter, string interpreterArgs, string script, string scriptArgs, string workingDir, Dictionary <string, string> env, bool openReport, string launchUrl, int?port, bool startBrowser)
        {
            if (String.IsNullOrWhiteSpace(interpreter))
            {
                Nodejs.ShowNodejsNotInstalled();
                return;
            }
            else if (!File.Exists(interpreter))
            {
                Nodejs.ShowNodejsPathNotFound(interpreter);
                return;
            }

            var arch = NativeMethods.GetBinaryType(interpreter);

            bool jmc = true;

            using (var vsperfKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings).OpenSubKey("VSPerf")) {
                if (vsperfKey != null)
                {
                    var value = vsperfKey.GetValue("tools.options.justmycode");
                    int jmcSetting;
                    if (value != null && value is string && Int32.TryParse((string)value, out jmcSetting))
                    {
                        jmc = jmcSetting != 0;
                    }
                }
            }

            var process = new ProfiledProcess(interpreter, interpreterArgs, script, scriptArgs, workingDir, env, arch, launchUrl, port, startBrowser, jmc);

            string baseName = Path.GetFileNameWithoutExtension(session.Filename);
            string date     = DateTime.Now.ToString("yyyyMMdd", CultureInfo.InvariantCulture);
            string outPath  = Path.Combine(Path.GetDirectoryName(session.Filename), baseName + "_" + date + ".vspx");

            int count = 1;

            while (File.Exists(outPath))
            {
                outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + "(" + count + ").vspx");
                count++;
            }

            process.ProcessExited += (sender, args) => {
                var dte = (EnvDTE.DTE)NodejsProfilingPackage.GetGlobalService(typeof(EnvDTE.DTE));
                _profilingProcess        = null;
                _stopCommand.Enabled     = false;
                _startCommand.Enabled    = true;
                _startCommandCtx.Enabled = true;
                if (openReport && File.Exists(outPath))
                {
                    dte.ItemOperations.OpenFile(outPath);
                }
            };

            session.AddProfile(outPath);

            process.StartProfiling(outPath);
            _profilingProcess        = process;
            _stopCommand.Enabled     = true;
            _startCommand.Enabled    = false;
            _startCommandCtx.Enabled = false;
        }