Updating configuration files with environment specific values

Jan 13, 2011 at 4:08 PM
Edited Jan 13, 2011 at 4:09 PM

Hello,

I would like to update a BizTalk 2010 configuration file with environment specific values so that I can have one configuration file that I can run with different values for dev/test/production.

For ex.

    <SQL ID="xxxxxxxxx" DisplayName="BizTalk Management Database" Description="This database is the central meta-information store for all BizTalk Servers.">
      <Server><Environment Specific Server name goes here></Server>
      <Database>Environment Specific Database name goes here></Database>
      <WindowsSecurity Editable="no">yes</WindowsSecurity>
      <UserName />
      <Password />
    </SQL

 

It is a fairly common task and I am aware of several options and would like to pick the easiest one to work with. Here are some

How do you currently handle this task in your environment? What are some of the things you like/dislike about your current approach?

Thanks,

Alper

Coordinator
Jan 14, 2011 at 4:37 PM

I use 

  • MSBuild.ExtensionPack.FileSystem.Detokenise class

extensively for this scenario. I should prob blog something...

Mike

Jan 14, 2011 at 8:16 PM

Is there way to provide replacement values from an external file? For example I have a file that contains environment specific values called Dev.ConfigValues.xml. Note that some values in the top section may be used more than once but I would like to have the actual value in one location only.

 

 
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<PropertyGroup>
	    <Domain>xxxx</Domain>
	    <UserName>dev_biztalkhost</UserName>
	    <Password>xxxxx</Password>
	    <Server>xxxxx</Server>
	    <BtsOperators>BizTalk Server Operators</BtsOperators>
            <BTS_HOST_NAME>$(BtsHostName)</BTS_HOST_NAME>
              ............
	    <BTS_OPERATOR_GROUP>$(BtsOperators)</BTS_OPERATOR_GROUP>
	    <BTS_B2B_OPERATOR_GROUP>$(BtsOperators)</BTS_B2B_OPERATOR_GROUP>
	    <BTS_HOST_NAME>$(BtsHostName)</BTS_HOST_NAME>
	    <BTS_HOST_INSTANCE_ACCT_USERNAME>$(UserName)</BTS_HOST_INSTANCE_ACCT_USERNAME>
	    <BTS_HOST_INSTANCE_ACCT_DOMAIN>$(Domain)</BTS_HOST_INSTANCE_ACCT_DOMAIN>
	    <BTS_HOST_INSTANCE_ACCT_PASSWORD>$(UserName)</BTS_HOST_INSTANCE_ACCT_PASSWORD>
	    .............
    </PropertyGroup>

</Project>

I would like to take the values above and merge it with the BizTalkConfig_Template.xml file that looks like this.

 

 
	......
         <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147483654">$(BTS_HOST_GROUP)</NTAccount>
        </NTCredential>
        <Name ID="BTS_HOST_NAME" DisplayName="Ho&amp;st name:" Description="Name of the In-Process BizTalk  host (eg, BizTalkServerApplication)" Hidden="false">
          <Value>$(BTS_HOST_NAME)</Value>
        </Name>
        <NTService ID="{B64F63FA-E24E-4991-86F0-ED9F65B68A98}" DisplayName="BizTalk Host Instance Account" Description="Windows account with access to a specific In-Process BizTalk host instance. This account will be given Log on as Service rights.">
          <UserName>$(BTS_HOST_INSTANCE_ACCT_USERNAME)</UserName>
          <Domain>$(BTS_HOST_INSTANCE_ACCT_DOMAIN)
          </Domain>
          <Password>$(BTS_HOST_INSTANCE_ACCT_PASSWORD)
          </Password>
        </NTService>
  .......

 

I guess I can convert the my values into the following format, put them in a separate project file and import that project file into the file that calls the Detokonize class. Any alternative ideas on Detokenize class usage?

        <ItemGroup>
            <TokenValues Include="Title">
                <Replacement>ANewTextString</Replacement>
            </TokenValues >
            <TokenValues Include="ProjectHome">
                <Replacement>www.codeplex.com/MSBuildExtensionPack</Replacement>
            </TokenValues >
        </ItemGroup>

Thanks,

Alper