It is not so strightforward as it suppose to be.
Below are the bat files with comments:
@rem ———– Deploy.Policies.bat ———————————————
@call Settings.bat
@call Settings.bat
@ECHO.
@ECHO. Deploy Policies:
@ECHO. ======================================================================
@ECHO.
@ECHO. Deploy Policies:
@ECHO. ======================================================================
@ECHO.
@Time /T
@ECHO 1) Create the ResourceSpec.xml file.
@rem BTSTask ListApp /ApplicationName:%ApplicationName% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase% /ResourceSpec:”%CurrentBuildPath%\ResourceSpec.xml
@ECHO 1) Create the ResourceSpec.xml file.
@rem BTSTask ListApp /ApplicationName:%ApplicationName% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase% /ResourceSpec:”%CurrentBuildPath%\ResourceSpec.xml
@Echo 2) Then edit it to remain only Policy recources.
@Echo 3) Export .xml to .msi
@rem BTSTask ExportApp /ApplicationName:%ApplicationName% /Package:”%CurrentBuildPath%\Policies.msi” /ResourceSpec:”%CurrentBuildPath%\ResourceSpec.xml” /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@rem BTSTask ExportApp /ApplicationName:%ApplicationName% /Package:”%CurrentBuildPath%\Policies.msi” /ResourceSpec:”%CurrentBuildPath%\ResourceSpec.xml” /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@Echo 4) Import .msi (Before this Undeploy the existed policies, the /Overwrite doesn’t help! Or Stop the Application.)
BTSTask ImportApp /Package:”%CurrentBuildPath%\Policies.msi” /ApplicationName:%ApplicationName% /Overwrite /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
BTSTask ImportApp /Package:”%CurrentBuildPath%\Policies.msi” /ApplicationName:%ApplicationName% /Overwrite /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@Echo 5) Deploy policies one by one :((
@set PolicyName=VesselID
@set PolicyVersion=1.27
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyVersion=1.27
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyName=CompanyID
@set PolicyVersion=1.0
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyVersion=1.0
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyName=PortOfUnloadingID
@set PolicyVersion=1.0
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyVersion=1.0
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyName=DocumentValidator
@set PolicyVersion=1.1
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@set PolicyVersion=1.1
BTSTask AddResource /ApplicationName:%ApplicationName% /Type:System.BizTalk:Rules /Overwrite /Name:%PolicyName% /Version:%PolicyVersion% /Server:%BizTalkDataBasesServer% /Database:%BizTalkConfigurationDataBase%
@Time /T
@rem call RestartBTS.bat
pause
@rem ———– Settings.bat ———————————————
@set MyShortSolutionName=MyShortSolutionName
@Set SolutionName=MyCompany.Domain.%MyShortSolutionName%
@set SolutionDir=C:\Solutions\%MyShortSolutionName%
@SET CurrentBuildPath=%SolutionDir%\Builds\Current
@SET BizTalkServer=BTS-06V
@SET BizTalkDataBasesServer=BTS-06V
@SET BizTalkConfigurationDataBase=BizTalkMgmtDb
@Set ApplicationName=%MyShortSolutionName%.MyApp