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 –
http://msdn2.microsoft.com/en-us/library/ms171451.aspx
http://www.codeproject.com/books/msbuild.asp.
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 –
Let’s see how MSBuild can help achieve this –
<Exec Command='"TF.exe get "$(TFSFolder)" /force /recursive'/>
<Exec Command='"devenv.exe" "TestSolution.sol" /Rebuild' />
Create BizTalk Application (Task <c>) example –
<Exec
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'/>
http://msdn2.microsoft.com/en-us/library/aa559686.aspx
http://msdn2.microsoft.com/en-us/library/aa560399.aspx
Limitations
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 - http://www.gotdotnet.com/codegallery/codegallery.aspx?id=b4d6499f-0020-4771-a305-c156498db75e. 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"/>
</Target>
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.
Thanks!