BTDF : handling multiple partial binding masters

Simon Emmanuel RIVAS
Category : BizTalk
08/10/2018

When you work on a BTDF project, having multiple partial binding masters (i.e : the complete binding master of the BizTalk application is split in many different files) can be useful in several respects :

  • More easily maintainable : you can group ports, parties and modulerefs in logical units, so you don’t have to skim through one monolithic binding master to make a change
  • In the same idea, if part of your binding is incorrect and can’t be imported, you will know right away which binding file failed to import in BizTalk, again making it much faster to debug
  • In incremental deployments, this allows to also partially update the binding of the BizTalk application.

 

The standard behavior of BTDF does not support multiple binding master files (you can only provide 1 file name in the PortBindingsMaster property). Note that I have found the following article on Technet, very interesting but addressing a different case : the author uses 1 binding master per environment (and each of the files being different of course) whereas we aim to use several binding masters regardless of the environment.

 

The solution is to disable the standard binding management feature of the BTDF and rely instead on the common XML preprocessing feature.

 

Here is how :

Build the master binding list

Edit your .btdfproj project file. Then for each binding master, add a FilesToXmlPreProcess item with a FileType element, as shown below :

<FilesToXmlPreprocess Include=”RelativePathToYouBindingMaster\Master.Binding.Flow1.xml”>

<OutputFilename>Binding.Flow1.xml</OutputFilename>
<FileType>binding</FileType>

</FilesToXmlPreprocess>

Override the default binding processing behavior

For this, you will have to edit the BizTalkDeploymentFramework.targets file (in C:\Progam Files (x86)\MSBuild\BizTalkDeploymentFramework\5.0) :

  • Completely remove the contents of the PreprocessBindings target
  • Replace the contents of the ImportBindings target with the following instructions :

<Target Name=”ImportBindings” DependsOnTargets=”InitializeAppName” Condition=”‘$(IncludeMessagingBindings)’ == ‘true'” >

<!– Only target the FilesToXmlPreprocess with FileType = ‘binding’  –>
<ItemGroup>
<DeployPortBindingsGroup Include=”%(FilesToXmlPreprocess.OutputFilename)” Condition=”‘%(FileType)’==’binding'” />
</ItemGroup>

<Message Text=”No binding file to process” Importance=”High” Condition=”‘@(DeployPortBindingsGroup)’==”” />
<!– Override the target application name –>
<WriteXmlValue XmlFilenames=”Resources\Bindings\%(DeployPortBindingsGroup.Identity)” XPath=”//ApplicationName” Value=”$(BizTalkAppName)” Condition=”‘@(DeployPortBindingsGroup)’!=”” />

<!– Import the binding files –>
<Exec Command=”BTSTask.exe ImportBindings -Source:&quot;Resources\Bindings\%(DeployPortBindingsGroup.Identity)&quot; -ApplicationName:&quot;$(BizTalkAppName)&quot;”
Condition=”‘@(DeployPortBindingsGroup)’!=”” />

<Pause Message=”Press a key to continue…” Condition=”‘$(Interactive)’ == ‘true'” />
<OnError ExecuteTargets=”PauseForError” />

</Target>

 

 

That should do the trick. Enjoy 😉