我正在制作 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/