This project has moved and is read-only. For the latest updates, please go here.

Pre-Process SettingsFileGenerator.xml

Topics: Bindings File, Settings Management and SSO, IIS and Web Services, Tips and Tricks
Feb 1, 2011 at 9:35 AM
Edited Feb 1, 2011 at 10:43 AM

The following are notes on how I implemented our requirement to deploy BizTalk applications on developer machines using bindings for web service receive locations secured using SSL\https.  I hope others find this useful.

Requirements

  • I want to test https receive locations that are secured in IIS using a certificate. (each machine has a certificate named the same as the machine name).
  • As such, these receive locations require clients to access them using a machine name (https://mymachinename/Service/MyService.svc) rather than using localhost (https://localhost/Service/MyService.svc).  Otherwise the client will receive an error such as “SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel”.
  • There are many development machines being used on the project including a build server.  As such, I need to deploy a BizTalk application with bindings for receive locations on developer machines that use the current machine name in the location URL.

To implement this, I did the following:


BizTalkDeploymentFramework.targets

  • In the C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets file, I have added a new customisable target called CustomPreExportSettings.  (Note: each developer will need to update this). 

  <PropertyGroup>
    <FrameworkInitializeDependsOn>
      Bootstrap;
      SetWinVer;
      GetSoftwarePaths;
      CustomPreExportSettings;
      ExportSettings;
      …
  <PropertyGroup>
    <PreprocessBindingsDependsOn>
      Bootstrap;
      GetSoftwarePaths;
      InitSettingsFilePath;
      CustomPreExportSettings;
      ExportSettings;
      ...
  <!-- Redefine in project file if required -->
  <Target Name="CustomPreExportSettings" />
  <Target Name="CustomDeployTarget" />

<Application>.Deployment project

  • In the EnvironmentSettings folder, I now have two excel xml files:
    • SettingsFileGeneratorMaster.xml
    • SettingsFileGenerator.xml
      (this second file is marked as excluded from source control so it can be updated)
  • The SettingsFileGeneratorMaster.xml file has values that are tokenised with #DeveloperMachineName#
  • In my application Deployment.btdfproj file, I have added the following target implementation of this CustomPreExportSettings

      <Target Name="CustomPreExportSettings;">

        <!-- Pre-Process SettingsFileGenerator.xml  -->
        <Exec Command="copy /Y .\EnvironmentSettings\SettingsFileGeneratorMaster.xml .\EnvironmentSettings\SettingsFileGenerator.xml"/>
        <File.Replace Condition="'$(Configuration)' != 'Server'" 
                             Path=".\EnvironmentSettings\SettingsFileGenerator.xml" 
                             RegularExpression="#DeveloperComputerName#"
                             NewValue="$(COMPUTERNAME)" />

      </Target>

BizUnit Test Project

  • In a similar way, I also needed to modify my BizUnit tests project.  I needed to update the WCF endpoint settings in the app.config file.  This is used by a custom BizUnit test step to fire messages to the BizTalk receive locations.  I re-used the Microsoft.Sdc.Common.tasks (as used by the BTDF) to achieve this in the project BeforeBuild target.

      <Import Project="..\References\Microsoft.Sdc.Common.tasks" />

      <Target Name="BeforeBuild">
        <!-- Updated app settings with local machine name -->
        <Exec Command="copy /Y .\AppMaster.config .\App.config" />
        <Microsoft.Sdc.Tasks.File.Replace Path=".\App.config" RegularExpression="#DeveloperComputerName#" NewValue="$(COMPUTERNAME)" />
      </Target>
Oct 18 at 5:00 PM
You can also inject ${_machine_name} into the EnvironmentSettings.xml.
A list of other properties are here: http://xmlpreprocess.sourceforge.net/content/properties.htm