gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 13:39:12 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com