Using BTDF to Deploy Pure WCF Services
October 19, 2014 9 Comments
The BizTalk Deployment Framework (BTDF) is widely used as a tool for managing the complex deployment requirements for BizTalk Server integration solutions. With each iteration, it gets better & better. The latest version (still in Beta) now supports BizTalk Server 2013 R2.
Of course at Mexia we use this tool quite regularly for our clients, enjoying the simplicity it affords in automated deployment and management of environment-specific configuration. However, the ESB that we often provide our customers includes more than just BizTalk applications; it includes some services implemented in pure WCF. Although these services do utilise BAM for tracking and SSO for configuration management, those features do not require the empty BizTalk application that is generated from using the BTDF.
After consultation with BTDF author Thomas Abraham and some helpful tips on this thread, I spent some time putting together a BTDF project file that would deploy just the bits that are needed for WCF – and nothing more. It has been very successful so far, providing for a consistent build definition and deployment process across the entire ESB platform. I’d like to share it with you here.
But before we go into the details, there are a few things you need to be aware of regarding this solution:
- This applies only to version 5.5 of the BTDF; the new version (6.0) incorporates a complete rebuild of the IIS virtual directory provisioning, and therefore the VDIR code in this version is irrelevant. Since our client had already invested heavily in v5.5, I had to stay confined to that release (but I hope to rewrite this solution in v6.0 someday when I get a chance to play with it).
- The IIS 6 Scripting Tools Windows feature must be enabled on your target system.
Setting the Project Options
When you first add a “Deployment Framework for BizTalk” project type to a solution, you are presented with a dialog allowing you to set a number of framework options. The items highlighted in yellow in this screenshot are the properties that you should change from their default settings:
However, this isn’t a comprehensive list of all the options; therefore I’ve included below the initial <PropertyGroup> listing from one of my project files to show the additional options that must be set:
<Configuration Condition=”‘$(Configuration)’ == ””>Debug</Configuration>
<Platform Condition=”‘$(Platform)’ == ””>x86</Platform>
Overriding the Default Targets
The key to understanding this solution is to be aware of the default MSBuild targets that are installed with BTDF and imported into every BTDF project file, using this line of code (near the bottom of the generated Deployment.btdfproj file):
<Import Project=”$(DeploymentFrameworkTargetsPath)BizTalkDeploymentFramework.targets” />
The BizTalkDeploymentFramework.targets file is located in the MSBuild folder, typically at “C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0”. There are two key items that establish the dependencies of both the Deploy and Undeploy targets:
- Each of these elements contains a delimited list of targets.
Thomas pointed out that you can override these elements in your own individual project file, which is key to controlling the target dependencies. Simply by removing the targets that are specific to BizTalk applications, you can restrict the build to containing just the items that are needed for WCF service deployment.
Simply add the following <PropertyGroup> block after the <Import> statement mentioned above:
<!-- THE FOLLOWING DEPLOY DEPENDENCIES HAVE BEEN REMOVED:
<!-- THE FOLLOWING UNDEPLOY DEPENDENCIES HAVE BEEN REMOVED:
I’ve included the removed elements in the commented blocks so you can see what exactly has been overridden. Feel free to adjust this list to suit your individual project purposes. Searching the BizTalkDeploymentFramework.targets file will show you what functionality is included in each of these targets.
Creating the IIS Bits
Next, simply use the out-of-the-box bits of the BTDF to arrange the setting up of your virtual directory and application pool. Note the this part has changed radically in version 6.0 of the BTDF – so please consult the documentation for learning about the new virtual directory handling in that version.
Although this is optional, I like to include a custom <PropertyGroup> section where I define some global variables:
Then I can reference these in the relevant VDIR bits:
<IisAppPools Include=”$(AppPoolName)” />
<Message Text=”Setting the AppPools to Integrated .NET v4.0…” Importance=”High” />
<Exec Command=”"$(AppCmd)" set apppool "$(AppPoolName)" /managedPipelineMode:Integrated /managedRuntimeVersion:v4.0″ Condition=”‘$(IisMajorVersion)’ == ‘7’” />
Be aware that nested virtual directories are not supported in version 5.5.
Don’t forget to add the VDIR_UserName and VDIR_PassName items to your environment settings list and in your SettingsFileGenerator.xml spreadsheet!
<PropsFromEnvSettings Include=”SsoAppUserGroup;SsoAppAdminGroup;VDIR_UserName;VDIR_UserPass” />
And that’s it! Your BTDF project will now deploy your WCF service along with any environment settings (e.g. configuration values stored in SSO) without creating a BizTalk application.