Build and generate MSI for BizTalk Server using Team Foundation Build Services

Build and generate MSI for BizTalk Server using Team Foundation Build Services

Using a build server and leveraging continuous integration is good practice in any software
development project. The idea behind automated build and continuous integrations is to have a server that
monitors one’s source code repository and builds the solution as changes occur. This separate build
activity alone will ensure that all artifacts are checked in and that a successful build doesn’t depend on any artifacts or settings on the development machines.

Build server

Today build servers do a lot more as part of the build – the build process usually involves execution of
tests, labeling the source as well as packing the solution into a deployable artifact.

In this post we’ll see how a build process can be achieved using Team Foundation (TFS) Build Services, building a BizTalk project that results in
a deployable MSI artifact.

TFS Build Services

TFS Build services is a component that is part of the standard TFS install media.
Each TFS build controller controls a number of “Build Agents” that will perform the actual build process. For each solution to build one has to
define its process. These processes are described in a “Build Template” that tells the agent what steps to go through
and in what order.

“Build Templates” in TFS Build Services are defined using Visual Studio. The image below shows a build template accessed through Visual Studio Team Explorer.

Visual Studio Team Explorer Build Templates

Major steps in a build template

As one creates a new build template for a solution one has to go through the following major steps:

1. Define a trigger

Decides what should trigger the build. Should it be triggered manually, should it be a scheduled build or should it
be triggered at a check-in of new code?

2. Source Setting

This will tell the build process what part of the source tree the build template is relevant for. When queueing
a new build this is the part of the source tree that will be downloaded to the staging area. It also tells the build
services where on disk the source should be downloaded to.

3. Process

This is where all the steps and activities that the build service should perform are defined. Team Foundation Build
Services comes with a number of standard templates and custom ones can be added. In this post we’ll however stick with the default one.

Build your first BizTalk solution

Building BizTalk Server solution using TFS Build Services is straight forward.

In this post I will use this sample BizTalk solution. After checking it into Team
Foundation Source Control (I’ll use TFS Source control in this post but it’ll work similarly using Git) I’ll create a new build template for the solution. All that’s
needed to change is the MsBuild platform setting property, so we’re using x86 when executing MsBuild as shown below.

Build process and the MsBuild platform setting property

After queuing a build we can in the TFS Build Explorer see a successful build!

Successful build in TFS Build Explorer

We can also download the output from the build where we can see all our build artifacts!
First artifact drop

Using BtsMsiTask to create a MSI as part of the build

So far so good, but we started the article by saying that what we wanted was a deployable artifact. In the case of
BizTalk this means a BizTalk MSI. Let’s see what we need to change to also have the build process create a MSI.

1. Install BtsMsiTask

Download and install BtsMsiTask. This will install a MsBuild task for generating the MSI.

2. Add a MsBuild project file

Add a MsBuild project file (build.proj) to the solution

The project file will tell the BtsMsiTask process what artifacts to include.
Add the created project file to the solution and check it in as part of the solution.

3. Add the MsBuild project file to the TFS build template

Add the created MsBuild project file to the TFS build template by adding it to the list of projects to build.

Adding the build file to the build process

After another successful build we can see that we also created a MSI as part of the build!
Successful build with msi

Adding build information to the MSI

File name

As we can see the MSI we just created ended up with the default BtsMsiFile name that is a combination of the BizTalk application name property and the
current date and time. Wouldn’t it be nice of we instead could the build number as part of the name?
BtsMsiTask has an optional property called FileName that we for
example can set to <FileName>$(TF_BUILD_BUILDNUMBER).msi</FileName>

Source location

When installing the artifact to BizTalk Server we can see that the source location property in the BizTalk Administration Console is set to
where the artifact was built on the staging area.
Source Location without build number

It’d be nice to also have information about what build that produced these artifacts. This will give the required information to know exactly what builds that are used for all the installed artifacts.

We can change what is set in the source location by using the SourceLocation property of BtsMsiTask <SourceLocation>c:$(TF_BUILD_BUILDNUMBER)</SourceLocation>

So after setting the property as below, queue another build, reinstall using the MSI and we’ll get the following result with the build number in the source location property.
Source Location with build number

And finally this is the MsBuild project file we ended up with in our example.

Receiving a RNIF exception: UNP.SCON.VALERR: A failure occurred while validating the service content while you are extending Microsoft BizTalk Accelerator for RosettaNet (BTARN) with a new Partner Interface Process (PIP) schema.

Receiving a RNIF exception: UNP.SCON.VALERR: A failure occurred while validating the service content while you are extending Microsoft BizTalk Accelerator for RosettaNet (BTARN) with a new Partner Interface Process (PIP) schema.

In my opinion there are a lack of documentation, or good documentation and many of the existing one is obsolete, regarding some topics/feature of BizTalk Server – Microsoft BizTalk Accelerator for RosettaNet is one of them. Today while I was trying to extend Microsoft BizTalk 2013 Accelerator for RosettaNet (BTARN) with a new receive Partner […]
Blog Post by: Sandro Pereira

Error while retrieving or generating the WSDL. Adapter message: Details: ErrorCode=RFC_EXCEPTION. ErrorGroup=RFC_ERROR_APPLICATION_EXCEPTION. SapErrorMessage=SEGMENT_UNKNOWN. AdapterErrorMessage=Error returned by RfcCallReceiveEx while calling RFC: IDOCTYP

Error while retrieving or generating the WSDL. Adapter message: Details: ErrorCode=RFC_EXCEPTION. ErrorGroup=RFC_ERROR_APPLICATION_EXCEPTION. SapErrorMessage=SEGMENT_UNKNOWN. AdapterErrorMessage=Error returned by RfcCallReceiveEx while calling RFC: IDOCTYP

Last week while trying to generate from Visual Studio 2013 a schema of a custom SAP IDOC by: Right-click your BizTalk Server project, and then choose “Add | Add Generated Items | Consume Adapter Service”. In the “Consume Adapter Service” Add-in screen, select the sap adapter binding. You should set the connection URI to SAP […]
Blog Post by: Sandro Pereira

BizTalk360 releases version 7.9

BizTalk360 releases version 7.9

BizTalk360 has released the brand new version 7.9 with some very promising new features. The new release brings some new features for making your life as a BizTalk administrator even easier. You can find this new version on their download page, just hit the link for downloading the latest msi setup or request for your […]
Blog Post by: mitchke

BizTalk Scheduled Task Adapter is now officially available for BizTalk Server 2013 R2

BizTalk Scheduled Task Adapter is now officially available for BizTalk Server 2013 R2

After many requests and many postponements, due to my unavailability and free time to take these tasks, BizTalk Scheduled Task Adapter is finally officially available (version 5.0) and optimized for BizTalk Server 2013 R2! You can download this new version of the adapter in BizTalk Scheduled Task Adapter CodePlex project page: Release 5.0 for BizTalk […]
Blog Post by: Sandro Pereira