Monday, August 6, 2012

BizTalk Business Rules Deployment in Command Line

Business rules is a good way to config the decision points, however, it will need to be included in your build script for automation.

BizTalk does not provide this out-of-the-box, you have to include them in the MSI.
However, there is a sample program to be build for it.
http://go.microsoft.com/fwlink/?LinkId=102220

This program needs to reference for Microsoft.BusinessRules and Microsoft.BizTalk.BusinessRulesExtension assmeblies, which are in c:\program files\common files\bizTalk folder.

When you run the program to undeploy a policy, if your policy name is in format as XXX.YYY.ZZZ, it will fail with an error "input string was not in correct format".

This because the program will split the policy name by '.' to understand there version number. A work around is to update the helper class included in the source code for the function ExtractPolicyNameMajorMinor. Update the line
from string[] arr = polNameWithVersion.Split('.');
to string[] arr = polNameWithVersion.Split('$');

In this way, the program will ignore the version number and undeploy them.
To use the program for deploy and undeploy from the powershell, it will be like the following.
invoke-expression("D:\Deploy\DeployRules.exe /I '{0}' /P /D" -f $filePath)
invoke-expression("D:\Deploy\DeployRules.exe /U /R /P:'{0}'" -f $ruleName)

Also you can easily use powershell to process the policy xml file to understand the policy name. Such as,
 $xml = [xml](Get-Content $filePath)
 $ruleName = $xml.brl.ruleset.Name


No comments: