public void WriteMessage(String message)
        {
            StringBuilder s = new StringBuilder();

            for (int i = 0; i < Indent; ++i)
            {
                s.Append(" ");
            }
            s.AppendLine(message);

            OutputPane.Activate();
            OutputPane.OutputString(s.ToString());
        }
Beispiel #2
0
        void Compile(string cl, string args, VCFile file)
        {
            Process process = new Process();

            process.StartInfo.FileName               = cl;
            process.StartInfo.Arguments              = args;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.WorkingDirectory       = Path.GetDirectoryName(m_dte.Solution.FullName);

            EnvDTE.Window           window       = m_dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
            EnvDTE.OutputWindow     outputWindow = (EnvDTE.OutputWindow)window.Object;
            EnvDTE.OutputWindowPane buildPane    = outputWindow.OutputWindowPanes.Item(BuildPaneName);
            buildPane.Clear();
            buildPane.Activate();

            process.OutputDataReceived += (sender, eventArgs) => BuildOutputReceived(buildPane, eventArgs);

            process.Start();
            process.BeginOutputReadLine();

            OnCompilationStart();
            System.Threading.Tasks.Task.Run(() => BuildTask(process, file));
        }
Beispiel #3
0
        public void Execute(string exe, string args, string workDir, bool showWindow)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            bool buildPaneIsActive = false;

            EnvDTE.OutputWindow     outputWin = getOutputWindow();
            EnvDTE.OutputWindowPane pane      = getOutputPane(_outputPane);
            if (outputWin != null && pane != null)
            {
                if (!buildPaneIsActive)
                {
                    outputWin.Parent.Activate();
                    pane.Activate();
                    buildPaneIsActive = true;
                }
                pane.Clear();
            }

            ProcessStartInfo si = new ProcessStartInfo();

            si.FileName               = exe;
            si.Arguments              = args;
            si.UseShellExecute        = false;
            si.RedirectStandardOutput = true;
            si.CreateNoWindow         = !showWindow;
            si.WorkingDirectory       = workDir;

            Process proc = new Process();

            proc.StartInfo           = si;
            proc.OutputDataReceived += new DataReceivedEventHandler(OnOutputDataReceived);
            proc.Start();
            proc.BeginOutputReadLine();
        }
Beispiel #4
0
        public void WriteMessage(string message)
        {
            ThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                StringBuilder s = new StringBuilder();
                for (int i = 0; i < Indent; ++i)
                {
                    s.Append(" ");
                }
                s.AppendLine(message);

                OutputPane.Activate();
                OutputPane.OutputString(s.ToString());
            });
        }
    private EnvDTE.OutputWindowPane LoadOutputWindowPane(DTE dte)
    {
        const string windowName = "pMixins Code Generator";

        EnvDTE.OutputWindowPane pane   = null;
        EnvDTE.Window           window = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
        if (window != null)
        {
            EnvDTE.OutputWindow output = window.Object as EnvDTE.OutputWindow;
            if (output != null)
            {
                pane = output.ActivePane;
                if (pane == null || pane.Name != windowName)
                {
                    for (int ix = output.OutputWindowPanes.Count; ix > 0; ix--)
                    {
                        pane = output.OutputWindowPanes.Item(ix);
                        if (pane.Name == windowName)
                        {
                            break;
                        }
                    }
                    if (pane == null || pane.Name != windowName)
                    {
                        pane = output.OutputWindowPanes.Add(windowName);
                    }
                    if (pane != null)
                    {
                        pane.Activate();
                    }
                }
            }
        }
        return(pane);
    }
        // 这个弹出框需要server参数,麻烦,用winform方便
        //public static void Info(IServiceProvider server, string msg, string title = "插件-信息提示")
        //{
        //    VsShellUtilities.ShowMessageBox(
        //       server,
        //       msg,
        //       title,
        //       OLEMSGICON.OLEMSGICON_INFO,
        //       OLEMSGBUTTON.OLEMSGBUTTON_OK,
        //       OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
        //}

        /// <summary>
        /// 在vs的输出窗口的标题为"web发布插件"的窗口里输出文本内容
        /// </summary>
        /// <param name="msg">文本</param>
        /// <param name="clear">是否清空原有信息</param>
        public static void VsOutWind(string msg, bool clear = false)
        {
            //ThreadHelper.ThrowIfNotOnUIThread();
            // 输出窗口集合
            EnvDTE.OutputWindowPanes panels =
                EnvVar._dte.ToolWindows.OutputWindow.OutputWindowPanes;
            // 输出窗口固定的自定义项标题
            string title = EnvVar.Name;

            try
            {
                // If the pane exists already, write to it.
                panels.Item(title);
            }
            catch (ArgumentException)
            {
                // Create a new pane and write to it.
                panels.Add(title);
            }
            EnvDTE.OutputWindowPane panel = panels.Item(title);
            // 清空消息
            if (clear)
            {
                panel.Clear();
            }
            // 激活输出窗口的该面板
            panel.Activate();
            // 输出消息
            panel.OutputString(msg);

            // 显示(激活) vs"输出"窗口
            string winCaption = "输出";

            EnvVar._dte.Windows.Item(winCaption).Activate();
        }
 private static void ShowOutputWindowPane(string paneName)
 {
     EnvDTE.OutputWindow     outputWindow = CodeRush.Windows.Active.DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object as EnvDTE.OutputWindow;
     EnvDTE.OutputWindowPane buildPane    = outputWindow.OutputWindowPanes.Item(paneName);
     System.Diagnostics.Debug.Assert(buildPane != null);
     buildPane.Activate();
     outputWindow.Parent.SetFocus();
 }
Beispiel #8
0
        private EnvDTE.OutputWindowPane GetOutputPane()
        {
            try
            {
                if (DTE == null)
                {
                    return(null);
                }

                string windowName              = GetType().Name;
                EnvDTE.OutputWindowPane pane   = null;
                EnvDTE.Window           window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
                if (window != null)
                {
                    EnvDTE.OutputWindow output = window.Object as EnvDTE.OutputWindow;
                    if (output != null)
                    {
                        pane = output.ActivePane;
                        if (pane == null || pane.Name != windowName)
                        {
                            for (int ix = output.OutputWindowPanes.Count; ix > 0; ix--)
                            {
                                pane = output.OutputWindowPanes.Item(ix);
                                if (pane.Name == windowName)
                                {
                                    break;
                                }
                            }
                            if (pane == null || pane.Name != windowName)
                            {
                                pane = output.OutputWindowPanes.Add(windowName);
                            }
                            if (pane != null)
                            {
                                pane.Activate();
                            }
                        }
                    }
                }
                return(pane);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #9
0
        public void Run()
        {
            using (TestRunnerServer server = new TestRunnerServer())
            {
                server.Complete += new CompleteHandler(OnComplete);
                server.Result   += new ResultHandler(OnResult);
                server.Error    += new ErrorHandler(OnError);

                EnvDTE.Process   attachedProcess;
                ProcessStartInfo psi = new ProcessStartInfo();
                Assembly         asm = typeof(ITestRunnerService).Assembly;
                psi.FileName               = asm.Location;
                psi.WorkingDirectory       = Path.GetDirectoryName(_assembly);
                psi.UseShellExecute        = false;
                psi.RedirectStandardOutput = true;
                psi.WindowStyle            = ProcessWindowStyle.Hidden;
                _process = Process.Start(psi);

                foreach (EnvDTE.Process p in _output.DTE.Debugger.LocalProcesses)
                {
                    if (p.ProcessID == _process.Id)
                    {
                        attachedProcess = p;
                        attachedProcess.Attach();
                        break;
                    }
                }

                string error = _process.StandardOutput.ReadToEnd();
                _process.WaitForExit();

                _output.OutputString("\n");
                _output.OutputString(error);

                _output.Activate();
                _status.Text = GetResultText();
            }
        }
Beispiel #10
0
        /// <summary>
        /// 输出信息到VS的"输出"窗口,如果"输出"窗口未打开,则打开后再输出
        /// </summary>
        /// <param name="msg"></param>
        internal static void OutPutMsg(string msg, bool clear = false)
        {
            EnvDTE.OutputWindowPanes panels =
                _dte.ToolWindows.OutputWindow.OutputWindowPanes;

            // 输出窗口中的一个自定义项的标题
            string title = "发布插件 消息";

            //
            EnvDTE.OutputWindowPane panel = null;
            foreach (EnvDTE.OutputWindowPane item in panels)
            {
                if (item.Name == title)
                {
                    panel = item;
                    break;
                }
            }
            if (panel == null)
            {
                panel = panels.Add(title);
            }
            // 清空消息
            if (clear)
            {
                panel.Clear();
            }
            // 激活输出窗口的该面板
            panel.Activate();
            // 输出消息
            panel.OutputString(msg);

            // 显示(激活) vs"输出"窗口
            string winCaption = "输出";

            _dte.Windows.Item(winCaption).Activate();
        }
Beispiel #11
0
        /// [exec start process]
        public void StartProcess(string exePath, string args, string workDir, bool enableBoostParsing)
        {
            try
            {
                // Ensure executable exists
                if (!System.IO.File.Exists(exePath))
                {
                    WriteLine(1, "Executable not found: " + exePath);
                    m_mainEvents.OnTestTerminated(Result.Failed, exePath, false, new TimeSpan(0), "Executable not found: " + exePath);
                    return;
                }

                // Ensure output pane exists
                if (m_outputPane == null)
                {
                    EnvDTE.OutputWindow ow = dte.ToolWindows.OutputWindow;
                    m_outputPane = ow.OutputWindowPanes.Add("Run UnitTest");
                }
                m_outputPane.Activate();
                m_outputPane.Clear();

                // -----  Prepare process data  -----
                m_process = new System.Diagnostics.Process();
                m_process.StartInfo.FileName         = exePath;
                m_process.StartInfo.WorkingDirectory = workDir;
                m_process.StartInfo.Arguments        = args.Trim();
                boostProcessOutputParser.Clear();
                boostProcessOutputParser.EnableParsing = enableBoostParsing;

                if (m_getNotificationWhenProcessTerminates)
                {
                    // Remark: Method Executor.Process_Exited will be called
                    // from some system thread when the process has terminated.
                    // Synchronization will be needed!
                    m_process.Exited += new System.EventHandler(Process_Exited);
                    m_process.EnableRaisingEvents = true;
                }

                if (m_catchStdOutAndStdErr)
                {
                    m_process.StartInfo.UseShellExecute        = false;
                    m_process.StartInfo.RedirectStandardOutput = true;
                    m_process.StartInfo.RedirectStandardError  = true;
                    m_process.StartInfo.CreateNoWindow         = true;
                    m_process.OutputDataReceived += new System.Diagnostics.
                                                    DataReceivedEventHandler(boostProcessOutputParser.StandardOutputReceiver);
                    m_process.ErrorDataReceived += new System.Diagnostics.
                                                   DataReceivedEventHandler(boostProcessOutputParser.StandardErrorReceiver);
                }

                // -----  Start the new process and start redirection of output  -----
                m_process.Start();
                if (m_catchStdOutAndStdErr)
                {
                    m_process.BeginOutputReadLine();
                    m_process.BeginErrorReadLine();
                }

                WriteLine(2, "Started " + m_process.StartInfo.FileName);
            }
            catch (Exception e)
            {
                string info = "EXCEPTION: Could not start executable " + exePath + " " + e.ToString();
                WriteLine(1, info);
                m_mainEvents.OnTestTerminated(Result.Failed, exePath, false, new TimeSpan(0), info);
            }
        }