我正在制作一个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已经输出。
接下来我可以尝试什么?