Merge Environmental Overrides Option During Nightly Build...

Topics: General discussion
Mar 2, 2007 at 1:52 AM
I love the Environmental Overrides and even wrote a quick post on it:

Environmental Overrides in Enterprise Library 3.0 - Managing Development, Test, Staging, and Production Configurations Made Easy!

but now I want to be able to silently kick off the "Save Merged Configuration" Option in the GUI Configuration Tool in my nightly build :)

Ideally I would like to be able to send the GUI tool or another console application my main config, delta config, and the path where I want the results to be merged ( or something along those lines ).

Build integration is a must have as this functionality screams for inclusion in my build file. Manually offering the option is nice, but most developers will want the merging to occur during build.

Regards,

Dave

____________________________

David Hayden
Microsoft MVP C#
Mar 2, 2007 at 3:47 PM
Hi Dave -

Take a look at the Configuration.EnvironmentalOverrides.Console project - this is designed for exactly this scenario.

Tom
Mar 2, 2007 at 5:32 PM
Tom,

Appears to be exactly what I am looking for.

Unfortunately, it doesn't seem to complete the merge although it says it is successful. The merged output file is exactly the same as my main configuration file.

I created a batch file that calls the following:

MergeConfiguration.exe App.config Production.dconfig .\Production.config
pause

Once completed, Production.config == App.config with no regards to my overrides in Production.dconfig.

Regards,

Dave

____________________

David Hayden
Microsoft MVP C#
Mar 2, 2007 at 6:42 PM
Interesting, I believe the arguments to the tool are correct.

Would you mind posting the contents of both the App.config and Production.dconfig -so we can have a look at what exactly happend.

Thanks
Olaf
Mar 2, 2007 at 6:58 PM
Absolutely,

My App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <dataConfiguration defaultDatabase="Connection String" />
  <connectionStrings>
    <add name="Connection String" connectionString="Data Source=.;Initial Catalog=Test;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

My Production.dconfig:

<configuration>
    <configSections>
        <section name="EnvironmentMergeData" type="Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.Configuration.EnvironmentMergeSection, Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </configSections>
    <EnvironmentMergeData environmentName="Production" environmentDeltaFile="Production.config">
        <mergeElements>
            <override nodePath="/Data Access Application Block/Connection Strings/Connection String"
                overrideProperties="true">
                <overridddenProperties>
                    <add name="ConnectionString" value="Data Source=.;Initial Catalog=Production;Integrated Security=True" />
                </overridddenProperties>
            </override>
        </mergeElements>
    </EnvironmentMergeData>
</configuration>

The results via the console application:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <dataConfiguration defaultDatabase="Connection String" />
  <connectionStrings>
    <add name="Connection String" connectionString="Data Source=.;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>


The results when using the Configuration GUI Tool ( works fine ):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <dataConfiguration defaultDatabase="Connection String" />
  <connectionStrings>
    <add name="Connection String" connectionString="Data Source=.;Initial Catalog=Production;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

Regards,

Dave

___________________

David Hayden
Microsoft MVP C#
Mar 13, 2007 at 11:04 AM
Copy the AppSettings.Configuration.Design.dll to the executable "MergeConfiguration.exe" folder and try...

Regards,
Srini
Feb 6, 2008 at 5:29 PM

DavidHayden wrote:
I love the Environmental Overrides and even wrote a quick post on it:


I'm really digging the environment merging too but actually want to use it on a non-entlib project. I can't. Here's the problem:

My original base.config file:
<configuration>
    <configSections>
    </configSections>
    <appSettings>
        <add key="timeout" value="60" />
    </appSettings>
</configuration>

I have an environment called QA and one called Production. In my Production override, I set timeout to a value of 180. When I create the merged file I get this:

<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <appSettings>
    <add key="timeout" value="180" />
  </appSettings>
</configuration>

The tool is adding in the dataConfiguration setting.

Anyway to not have it do this? If I load up this config file in an application where Microsoft.Practices.EnterpriseLibrary.Data.dll isn't deployed, is this going to be a problem?