Using config transforms with EPiServer

This article was migrated from an older iteration of our website, and it could deviate in design and functionality.


Config transforms are great for configuration management. This post mentions one approach for applying config transforms to EPiServer configuration files such as episerver.config.

Estimated read time : 3 minutes

Jump to

Adding a config transform file for episerver.config

A while back I blogged about using config transforms with EPiServer. In that post I resorted to moving the <episerver> element into web.config without the custom EPiServer XML namespace to make it easier to have the config transform applied without any customization of the build process.

Keeping configuration files separated

Since then I’ve gone a different route where episerver.config is still a separate file, intact with its original XML namespace. I then use MSBuild to have the config transform be applied on every build:

Applying a config transform using MSBuild

Note that we use the configuration name (such as “Debug” or “Release”) to determine which transform to apply).

Executing the MSBuild script

In order to have the MSBuild script execute on every build we add it as a post-build event (the <TransformXml> task is included in the MSBuild script inside the ConfigTransform.xml file):

Executing MSBuild script as a post-build event

Configuration files in a separate folder

This means we keep all configuration files in a separate folder which is under version control:

image

Then, on every build, config transforms are applied and the resulting transformed configuration files are copied to the website root.

Contents of episerver.Debug.config

In order to make the config transform file for episerver.config work you have to include the custom XML namespace (in addition to the config transform namespace) like so:

Config transform file with custom XML namespace

More on config transforms

Here’s the original post on using config transforms with EPiServer. It explains how to apply config transforms for EPiServer settings such as VPP paths and site settings attributes.