我有一种情况是在多线程中使用 MSBUILD 构建多个解决方案,但是在构建过程中,总是很少有解决方案失败。我已经尝试一个一个地构建每个解决方案,它工作得很好。但我尝试使用多线程构建 5 个解决方案,很少构建失败。当我调查成功构建和失败构建的构建日志文件时,似乎 MSBUILD 与每个构建过程发生冲突。作为参考,我附上了两个构建日志的文本文件。
[为提交 ID 11468 构建开始] https://i.stack.imgur.com/KbaJb.png
[为提交 ID 11468 构建开始] https://i.stack.imgur.com/K1BOU.png
using (BuildManager objBuildManager = new BuildManager())
{
BuildRequestData BuildRequest = new BuildRequestData(SolutionPath, GlobalProperty, "14.0", new string[]
{ "Build" }, null,
BuildRequestDataFlags.ReplaceExistingProjectInstance);
BuildResult buildResult = objBuildManager.Build(bp, BuildRequest)
if (buildResult.OverallResult == BuildResultCode.Success)
{
buildPath = Convert.ToString(buildResult.ResultsByTarget.FirstOrDefault(x =>
x.Key == "Build").Value.Items[0]);
}
}