如何获得构建/重建实时输出

时间:2012-10-26 13:06:15

标签: c# visual-studio vspackage processstartinfo

我正在制作Visual Studio包,我启动devenv.exe并尝试构建其他解决方案。我需要实时构建输出,因此用户可以看到建立进度(输出),但我不知道如何这样做,如果可能的话。

我试过这样的方式:

            string rebuildLog = string.Empty;
            string logFileName = System.IO.Path.GetTempFileName();

            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
            psi.FileName = @"devenv.exe";
            psi.Arguments = "\"" + config.DmsPath + "\"" + @" /rebuild" + " Release|x64 " +" /out " + logFileName;

            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo = psi;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute = false;

            process.Start();

            while (!process.StandardOutput.EndOfStream)
            {
                string line = process.StandardOutput.ReadLine();
                MessageBox.Show(line); // just to see if it works. It should go to log form
            }


            rebuildLog = GetRebuildLog(logFileName);

而且rebuildLog有输出。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:10)

我找到了答案。 devenv.exe不写简单的控制台输出,所以我不得不改变

psi.FileName = @“devenv.exe”; psi.FileName = @“devenv。 com ”;它起作用了。