我正在制作 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 有输出。
有人可以帮忙吗?