Executing a command during a BTDF Deployment or Undeployment
Recently I came across the need to execute a command and script after a Biztalk deployment using the BizTalk Deployment Framework (BTDF). In order to accomplish this BTDF allows the use of two specific deployment ‘Targets’ in the btdfproj file. Each one will allow the execution of custom deployment or undeployment steps. The ‘CustomDeployTarget’ tag allows for execution early on in the deployment process, while the ‘CustomUndeployTarget’ allows for execution early in the undeploy process.
In order to use either, you can add the following tags to the end of the btdfproj file after the <Target Name=”CustomRedist “></Target> element:
1: <Import Project="$(DeploymentFrameworkTargetsPath)BizTalkDeploymentFramework.targets" />
3: The Deployment Framework automatically packages most files into the server install MSI.
4: However, if there are special folders that you need to include in the MSI, you can
5: copy them to the folder $(RedistDir) in the CustomRedist target.
6: To include individual files, add an ItemGroup with AdditionalFiles elements.
8: <Target Name="CustomRedist">
10: <Target Name="CustomDeployTarget">
11: <Exec Command="my_command_to_execute" />
13: <Target Name="CustomUndeployTarget">
14: <Exec Command="my_command_to_execute" />
Also, you can use the “BeforeTargets” and “AfterTargets” Target attributes to execute your target before or after a specific stage in the deployment or undeployment.