Microsoft.Build没有正确重建

时间:2012-08-21 11:35:45

标签: msbuild msbuild-4.0

我们正在修改在Visual Studio解决方案中重建所有内容的应用。我们使用的是BuildEngine,但由于它已被弃用,我们将转向Microsoft.Build。

代码是这样的:

var projectCollection = new Microsoft.Build.Evaluation.ProjectCollection();
var globalProperty = new Dictionary<String, String>();
var buildRequest = new Microsoft.Build.Execution.BuildRequestData(Directory.GetFiles(@"Build\", "*.sln").First(), globalProperty, null, new String[] { "Clean", "Build" }, null);

Microsoft.Build.Execution.BuildManager.DefaultBuildManager.Build(new Microsoft.Build.Execution.BuildParameters(projectCollection), buildRequest);

// 2nd time's a charm?
// Microsoft.Build.Execution.BuildManager.DefaultBuildManager.Build(new Microsoft.Build.Execution.BuildParameters(projectCollection), buildRequest);

但项目没有重建。但是,如果Build方法运行两次(如上面的注释代码),则可以正确地重建项目。

0 个答案:

没有答案