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:
<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>
<!-- 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…
Update: Are you getting an error like this: “The specified configuration and platform ('Debug/Any CPU') is not defined.” — right at the point that test results are supposed to be published? I don’t entirely understand this, except to say that something in the core TFS targets is apparently responsible for populating the Platform_Flavors table in the TfsBuild database. This step might not happen if you take over compiling by calling devenv.exe. Take a look in that table to see if the platform/flavor you are trying to use is listed there…
Scott Colestock lives, writes, and works as an independent consultant in the Twin Cities (Minneapolis, Minnesota) area.