コード例 #1
0
        internal async System.Threading.Tasks.Task ProfileProject(SessionNode session, EnvDTE.Project projectToProfile, bool openReport)
        {
            if (!await UIThread.InvokeTask(() => EnsureProjectUpToDate(projectToProfile)) &&
                await UIThread.InvokeAsync(() => MessageBox.Show(Resources.FailedToBuild, Resources.NodejsToolsForVS, MessageBoxButton.YesNo)) == MessageBoxResult.No)
            {
                return;
            }

            var    interpreterArgs = (string)projectToProfile.Properties.Item("NodeExeArguments").Value;
            var    scriptArgs      = (string)projectToProfile.Properties.Item("ScriptArguments").Value;
            var    startBrowser    = (bool)projectToProfile.Properties.Item("StartWebBrowser").Value;
            string launchUrl       = (string)projectToProfile.Properties.Item("LaunchUrl").Value;

            int?port = (int?)projectToProfile.Properties.Item("NodejsPort").Value;

            string interpreterPath = (string)projectToProfile.Properties.Item("NodeExePath").Value;

            string startupFile = (string)projectToProfile.Properties.Item("StartupFile").Value;

            if (String.IsNullOrEmpty(startupFile))
            {
                MessageBox.Show("Project has no configured startup file, cannot start profiling.", Resources.NodejsToolsForVS);
                return;
            }

            string workingDir = projectToProfile.Properties.Item("WorkingDirectory").Value as string;

            if (String.IsNullOrEmpty(workingDir) || workingDir == ".")
            {
                workingDir = projectToProfile.Properties.Item("ProjectHome").Value as string;
                if (String.IsNullOrEmpty(workingDir))
                {
                    workingDir = Path.GetDirectoryName(projectToProfile.FullName);
                }
            }

            RunProfiler(
                session,
                interpreterPath,
                interpreterArgs,
                startupFile,
                scriptArgs,
                workingDir,
                null,
                openReport,
                launchUrl,
                port,
                startBrowser
                );
        }