我通过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(); }
命令行编译的话请使用msbuild.exe...