How to minimize duplication between app.config.transform and web.config.transform within the same package?

Topics: General
Jan 16, 2014 at 3:45 PM
Edited Jan 16, 2014 at 3:46 PM
I am looking for a way to minimize the need for duplication when providing .transform files as part of our in-house NuGet package.

I have a setup as follows:
  • Foo.Services: A class library which contains the Service References to the used web services. This library calls and consumes the web services.
  • Foo.Web: A web application which uses Foo.Services.
  • Foo.Console: A console application which uses Foo.Services.
The Foo.Services library will be provided as a NuGet package. The connection strings and binding configurations for the web services used by Foo.Services are provided by a number of transformation files, one for each environment:
  • app.Debug.config.transform
  • app.Testing.config.transform
  • app.Release.config.transform
  • web.Debug.config.transform
  • web.Testing.config.transform
  • web.Release.config.transform
When adding the NuGet package to the solution the transformations are correctly applied to the corresponding config files.

As you might suspect, the app.Debug.config.transform and web.Debug.config.transform files are identical. This means that we must remember to update both files when a value in one of them changes. Is there a way to minimize this duplication?

For a while I thought about moving the actual configuration in another .config file which would then be included, but the problem is that I have other packages who use the same configuration section, so that's not an option.

Any thoughts or suggestions are greatly appreciated.