在Biztalk 2009和2010 .btproj项目中提供增量构建支持吗? [英] Incremental build support in Biztalk 2009 and 2010 .btproj projects?

查看:87
本文介绍了在Biztalk 2009和2010 .btproj项目中提供增量构建支持吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在追求增量构建时间改进的同时,我发现.btproj文件以及所有其他依赖于这些文件的项目都是在每个增量构建上重建的(部分).一直跟踪到BizTalkCommon.targets,我发现它对程序集进行了2遍编译-但只有第一遍会考虑已构建的工件,从而破坏了依赖链的增量部分.可以在BizTalkCommon.targets(第228行)中看到有问题的目标:

While chasing incremental build time improvements, I found that .btproj files and thus all other projects that depend on these are rebuilt (partly) on each incremental build. Tracking this all the way to BizTalkCommon.targets, I found that it does a 2 pass compilation of the assembly - but only the first pass respects already built artifacts, thus breaking the incremental part of the dependency chain. The offending target can be seen in BizTalkCommon.targets (line 228):

<!-- Delete the assembly and rerun the build process -->
<Target Name="SecondPass"
        Condition="$(SecondBuild)!=true and $(TempAssemblyOnly)!=true">

    <Delete Files="@(IntermediateAssembly)" />
    <MSBuild Projects="$(MSBuildProjectFile)" Properties="SecondBuild=true"/>
</Target>

我意识到进行2遍构建是有原因的,但是根本无法相信不可能为目标指定适当的输入和输出以正确处理增量构建.

I realize that there's a reason for the 2 pass build, but simply cannot believe it wouldn't be possible to specify appropriate in- and outputs for the target to handle incremental builds correctly.

有人知道.targets文件是否有补丁,还是有另一个很好的理由不支持增量构建?

Does anyone know if there's a patch for the .targets file, or if there's another good reason that incremental builds aren't supported?

推荐答案

您可以通过一些非常简单的更改来启用MSBuild BizTalk项目的增量编译.基本上,您需要覆盖BizTalkCommon.targets文件中定义的两个目标.

You can enable incremental compilation of MSBuild BizTalk project with a couple of very simple changes. Basically, you need to override two targets that are defined in the BizTalkCommon.targets file.

这些目标可以在您自己的.btproj文件中覆盖,并且不需要修改BizTalk附带的原始.targets文件.

Those targets can be overriden in your own .btproj files and do not require modifying the original .targets file that ships with BizTalk.

方法

首先创建您自己的.targets文件以托管您的自定义内容,例如BizTalkCustom.targets:

First Create you own .targets file to host your customizations, for instance BizTalkCustom.targets :

<Import Project="$(MSBuildExtensionsPath)\Microsoft\BizTalk\BizTalkC.targets" />

<!-- Rerun the build process (second pass) -->
<Target Name="SecondPass" Condition="$(SecondBuild)!=true and $(TempAssemblyOnly)!=true and @(XLang)!=''">
    <MSBuild Projects="$(MSBuildProjectFile)" Properties="SecondBuild=true" />
</Target>

<!-- Compile XLang/s orchestration -->
<Target
    Name="CompileODX"
    Condition="$(SecondBuild)==true"
    Inputs="@(XLang);$(MSBuildAllProjects);$(ClrTypesAssembly)"
    Outputs="$(BuildDone)">

  <!-- Delete previously generated C# files from XLang compilation -->
  <Delete Files="@(IntermediateAssembly)" />
  <Delete Files="@(CSharpOutputFromXLang)" />

  <XLangTask XLangItems="@(XLang)"
             ProjectReferences="@(ReferencePath)"
             WarningLevel="$(WarningLevel)"
             BpelCompliance="$(BpelCompliance)"
             DefineConstants="$(DefineConstants)"
             TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
             TempAssembly="$(ClrTypesAssembly)"
             OutputDirectory="$(XLangOutputPath)">
  </XLangTask>
</Target>

然后,替换您的.btproj文件中的最后一个Import语句:

Then, replace the last Import statement in your .btproj file:

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MyCustomExtensions)\BizTalkCustom.targets" />

它如何工作

BizTalk Server项目需要以某种方式分两步进行编译.第一遍编译架构,映射和管道,而第二遍编译编排.

BizTalk Server projects need somehow to be compiled in two passes. The first pass compiles schemas, maps and pipelines, whereas the second pass compiles orchestrations.

您会注意到,被覆盖的目标与在BizTalkCommon.targets file内部定义的原始目标非常相似.实际上,我做了两个简单的更改:

You'll notice that the overriden targets are very very similar than the original ones, defined inside the BizTalkCommon.targets file. In fact, I made two simple changes:

  1. 第一个更改涉及修改SecondPass目标并在Condition属性中添加额外的测试.如果您的项目甚至没有编排,此测试对于防止第二次通过也很有用.

  1. The first change involves modifying the SecondPass Target and adding an extra test in the Conditionattribute. This test is usefull to prevent the second pass from occurring if your project does not even have Orchestrations.

不幸的是,如果您的项目包含编排,原始的SecondPass目标将删除中间程序集,然后继续编译编排.但是,如果所有文件都是最新的,则无需运行CompileODX目标.因此,第二个更改涉及将Delete任务从SecondPass目标移动到CompiledODX目标.

Unfortunately, if your project contains Orchestrations, the original SecondPass Target deletes the intermediate assemblies and then proceed to compile the Orchestrations. However, the CompileODX Target does not need to run if all files are already up to date. Therefore, the second change involves moving the Delete Task from the SecondPass Target to the CompiledODX Target.

仅此而已.

这篇关于在Biztalk 2009和2010 .btproj项目中提供增量构建支持吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆