A few folks have discussed the topic of building BizTalk solutions with TFS, namely here and here.
As most have surmised in the time since TFS originally shipped, you have to build
BizTalk solutions with “devenv.exe” if you are going to use Team Build,
by overriding the “AfterCompile” target. This is because there is
no “standalone” xlang compiler (at least not that you & I can
use) – it instead loads in-process to the IDE.
Your steps will be something like the following:
-
Do a “developer tools only” install of BizTalk on your build server.
No need to install the BizTalk services or databases, etc. (unless you intend to deploy
& run post-deployment tests on the build machine.) Note that since you need
to install Team System Dev or Test to run post-build unit tests anyway, you aren’t
really installing that many more “bits” on your build server (if you are
skipping the BizTalk runtime/database infrastructure.) -
Comment out the line in your TFSBuild.proj file that looks like this: <SolutionToBuild
Include=”$(SolutionRoot)\path\MySolution.sln” /> - Create an AfterCompile target that looks something like this:
<Target Name="AfterCompile">
<!--Call DevEnv to build the BizTalk Solution-->
<Exec Command=""C:\%programfiles%\Microsoft Visual Studio
8\Common7\IDE\devenv" "$(SolutionRoot)\BizTalk\Dev\MyBizTalk.sln"
/Build "$(BuildFlavor)|$(BuildPlatform)""/>
<!-- Create a drop location -- >
<MakeDir
Directories="$(DropLocation)\$(BuildNumber)\$(BuildFlavor)"
Condition="!Exists('$(BinariesRoot)\$(BuildFlavor)')" />
<!-- Do whatever work you would like here - assemble binaries,
build an MSI via WiX, etc. and
place the outputs in the drop location.
-->
</Target>
What isn’t immediately obvious is that if you want to execute unit tests as
part of your build process (i.e. tests that don’t require your BizTalk solution
to be deployed…think build verification) then the DevEnv method of building
can cause you trouble. The testing portion of the build process expects your
binaries to land in the “Binaries” folder — a peer of Sources, BuildType,
and TestResults in your build location.
Therefore…you will want to add something like this at the end of your AfterCompile
target:
<!-- Get our build outputs into the "binaries" folder
to facilitate unit testing. -->
<MakeDir Directories="$(OutDir)"/>
<CreateItem Include="$(SolutionRoot)\**\*.dll" >
<Output ItemName="FilesToCopy" TaskParameter="Include"
/>
</CreateItem>
<Copy
SourceFiles="@(FilesToCopy)"
DestinationFolder="$(OutDir)"
ContinueOnError="true" />
With this in place, the unit testing portion of the build process can execute as if
you hadn’t resorted to calling devenv.exe…