[英]How do I know if compilation was sucessful or it failed with process.start() and devenv.exe?
I have the following code which builds a project using Process.Start() and devenv.exe:我有以下代码使用 Process.Start() 和 devenv.exe 构建项目:
RegistryKey rkey = Registry.LocalMachine;
//找到devenv.exe路径
RegistryKey rkey1 = rkey.OpenSubKey(REGISTKEY, false);
string devenvPath = rkey1.GetValue("").ToString();
ProcessStartInfo startInfo = new ProcessStartInfo(devenvPath);
startInfo.Arguments = "/rebuild \"debug|x86\" " + solutionPath;
//执行编译过程
Process process = new Process();
process.StartInfo = startInfo;
try
{
process.Start();
process.WaitForExit();
}
How can I detect whether the compilation was successful or not?如何检测编译是否成功?
DevEnv.exe sets an exitcode
when the build fails. devenv.exe的设置了一个exitcode
当构建失败。 Simply read out this exitcode and check if it is non-zero.只需读出此退出代码并检查它是否为非零。 There are a lot of questions on StackOverflow on that particular topic, but essentially what you need to do is关于该特定主题的 StackOverflow 上有很多问题,但基本上你需要做的是
process.WaitForExit();
bool isCompilationSuccesful = (process.ExitCode == 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.