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

标签 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有输出。

接下来我可以尝试什么?

最佳答案

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

psi.FileName = @"devenv.exe"; to psi.FileName = @"devenv.com";它奏效了。

关于c# - 如何获得构建/重建实时输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13087499/

相关文章:

c# - DLL 中的类

对象的 C# 随机代码字段生成器

c# - 在 .NET 中将 int 转换为 byte[4]

c# - 为什么可以将属性命名为其返回类型?

c# - Visual Studios C# - 页面刷新时重新调用类

c++ - 纹理数组,创建纹理

visual-studio - "There appears to be a discrepancy between the solution' s 源代码控制 ...."

app-config - 更改 Visual Studio 包中的配置文件

visual-studio-2010 - 如何调试 VSPackage 项目

.net - 检测 VSPackage 中的 Visual Studio 版本