Creating Automated Build Script for BizTalk using MSBuild

I saw lots of people talking about BizTalk build automation scripts and they are mostly curious about how MSBuild can help fix things. I thought of sharing potential and my experience of writing automated build script using MSBuild tasks. I am expecting readers to have some fundamental understanding of MSBuild, if not then please have a quick study at following links –


I am not going to talk about MSBuild itself or the best practices around MSBuild (that could be a separate article in itself) but I will talk about using MSBuild in BizTalk project related build automations.


Understand with Example


Let’s take a simple example. In a typical BizTalk 2006 implementation, you will like to do following build activities –


  1. Get latest code from source control

  2. Build solutions

  3. Create BizTalk Applications

  4. Add BizTalk resources (dlls, bindings etc.) to BizTalk applications.

  5. Import binding file to create ports and bind to orchestrations

  6. Export BizTalk application as MSI package (so that it can be deployed on testing/production machines)


Let’s see how MSBuild can help achieve this –


  1. Accomplishment of task <a> depends on source control used. It could be TFS, VSS, Source Depot anything. In general, we can use <Exec Command='<command>' /> MSBuild task to perform this job where command will use source control command line utility (e.g. TF.exe in case of TFS) to get latest code from source control database. Alternative, we can also use solution build framework (SBF) which provides VSS, source depot specific MSBuild task to perform job. We will talk about SBF later which is a wonderful extension over MSBuild. For example if TFS is the source control then we can use following command –


<Exec Command='"TF.exe get "$(TFSFolder)" /force /recursive'/>


  1. To execute task <b>, we can use exec task (<Exec />) along with Microsoft development environment command (devenv.exe). Example –


      <Exec Command='"devenv.exe" "TestSolution.sol" /Rebuild'  />


  1. Now comes the interesting part for any BizTalker. Tasks <c>, <d>, <e> and <f> can be achieved using two approaches – using MSBuild <exec> task with BizTalk command line utilities or using SBF. Lets see how first approach works –


Create BizTalk Application (Task <c>) example –



Command ='"$(BtsInstallLocation)\BTSTask" AddApp   /ApplicationName:TestBtsApplication' />


Add BizTalk dll (Resource) to BizTalk Application (Task <d>) example –


<Exec Command ='"$(BtsInstallLocation)\BTSTask" AddResource /ApplicationName:TestBtsApplication /Type:System.BizTalk:BizTalkAssembly /Overwrite /Source:SampleOrchestration.dll /Options:GacOnInstall,GacOnImport'/>


Import Binding File to BizTalk Application (Task <e>) example –


<Exec Command ='"$(BtsInstallLocation)\BTSTask" ImportBindings /ApplicationName: TestBtsApplication /Source:SampleBinding.xml'/>


Export BizTalk Application into MSI package (Task <f>) example –


<Exec Command ='"$(BtsInstallLocation)\BTSTask" ExportApp /ApplicationName: TestBtsApplication /Package:TestBtsApplication.Setup.msi'/>


  1.  That’s it. With simple recipe of MSBuild tasks and BTS command line utilities, we can achieve most of the things we wish for build automation. This example is not end of world; you can accomplish numerous other tasks related to BizTalk application, resources, bindings, web service publishing etc. I suggest you to refer following links to realize other capabilities of BizTalk command line utilities.





Are we done? Can we achieve everything using MSBuild tasks command line utilities? Unfortunately no because BizTalk does not offer command line utilities for many simple but much needed tasks such as start/stop BizTalk application, exporting schema, rule policies related tasks etc.


One solution is to use BizTalk Explorer Object Model to create custom MSBuild tasks (Implement ITask). Other is to reuse existing custom implementation done by others. And here comes Solution Build Framework in picture which is a brilliant in-house development done by MCS, UK.


Using Solution Build Framework (SBF)


You can find solution build framework at following location - SBF has extended MSBuild extensively to address wide variety of tasks including build/deployment related tasks for BizTalk 2006.


Just have a look at custom task list in attached text document. It is awesome.


To use SBF, you need to

Ø       download it from above link

Ø       Unzip task binaries (Microsoft.Sdc.Tasks.dll etc)

Ø       Include task list file (“Microsoft.Sdc.Common.tasks” containing “<UsingTask/>” statements) in your script file.

Ø       Finally start using SBF custom tasks in your script.


You can read help file (Microsoft.Sdc.Tasks Documentation.chm) to understand capability and usage of SBF tasks in details. SBF also provides guidelines and sample scripts for quick start and best practices.


Lets see how can we start a BizTalk application which is not possible with out of box BizTalk command line utilities –


<Import Project="Microsoft.Sdc.Common.tasks" />

<Target Name="StartBizTalkApplications">

<BizTalk2006.Application.Start Application="Test Application"/>



There are still some tasks which cannot be done in SBF such as rule policies related tasks, schema publishing tasks etc and here field is open for people like us to fill the gap.


There are endless things which are demanded for automated build. Most of them can be done using MSBuild and SBF while for other we can use adhoc custom developed tasks or manual steps.


I suggest you to start using these capabilities in projects because they add tremendous value to team development environment. If you have any query/issue, please feel free to ping me on my blog.



SBF Custom Tasks List.txt

Comments (10)
  1. Brajendra,

    While I think that any little bit helps, I think the solution you present is not acceptable long-term.  The complete lack of BizTalk integration with MSBuild (or anything else in VS.NET, for that matter) should be embarrassing for the BTS development team.

    If Microsoft wants great development shops to use BTS, the BTS PMs and developers should start caring about things that great development shops care about (e.g. automated builds, unit testing, etc.).

  2. John Dhom says:

    You wouldn’t typically have installed on a build server. You should be able to script the build without having to resort to Same goes for the need to install BizTalk on a build server. Developer licenses/installs are understandable… but not build server licenses/installs.


    John Dhom

  3. brajens says:

    John, you are not required to have installed on build machine. .net framework 2.0 is sufficient. you can write these scripts on dev machine using or on build machine using notepad/wordpad etc.

    Similarily developer license on build machine is sufficient.

  4. Brajendra,

    How would you get around having Visual Studio installed on the build server?  Your example shells out to Visual Studio to perform the build.

    Are you implying that the build should only run on the developer workstation?  What about CI builds?  Our company (and I’m sure Microsoft as well) does not deploy software built on a developer machine.

    The fact of the matter is that "normal" .NET software can be built on a machine with only the SDK installed and BizTalk does not have a similar facility.


  5. brajens says:

    You are right. I hope Microsoft will standardize BTS project to make compatible with msbuild. Then SDKs would be sufficient to run build script on any machine.

  6. Rachana says:


    I am trying to do an automated build and deploy of my biztalk solution using Cruise have installed .net as well as biztalk (not configured) on my build server.

    i am trying to execute the command line utility "Command=’"devenv.exe"" for build. However,it is still not building the biztalk dll’s.

    Any suggestions for automating and build and deploy of biztalk solution.?

  7. brajens says:

    Hi Rachana

    What error you are getting when trying to build using devenv command?

  8. rachana says:

    Thanks BJ. My Automated build and deploy is working fine.I had to use "Command=’"" and it worked.yopur article was a great starting point.

  9. Sulaiman says:

    Hi BJ

    Just happend to see ur blog on the MSBuild .

    I am very happy & surprised to see your artcile & Rachana’s comments.

    Thanks & Regards,


  10. Hi Brajendra,

    Thanks for the input, I’m trying to get the build process working with tfs and biztalk, but I’m still out of luck. Would you mind posting an entire sample of the tfsbuild.proj file.



Comments are closed.

Skip to main content