Using config transforms with EPiServer

This post shows how to apply config transforms to elements with custom XML namespace attributes, such as the EPiServer element.

  • 30 June 2011
  • 0

Update: Applying config transforms to elements with custom XML namespaces can be done much easier as described in this post on how to apply config transforms to episerver.config.

Config transform for EPiServer without removing ‘xmlns’

I previously gave some examples on using config transforms for EPiServer settings, which makes configuration management a lot easier. However, in that post I resorted to a “workaround” because the config transforms would fail for the <episerver> element because of its xmlns attribute. This post shows how to do it properly without removing the xmlns attribute.

Adding the custom EPiServer XML namespace

First of all we need to open our transform file, for example Web.Debug.config, and add the custom EPiServer XML namespace to it:

<configuration xmlns:epi="http://EPiServer.Configuration.EPiServerSection" xmlns:xdt="">

Note that we gave the namespace a prefix of “epi”. Next, we use this “epi” prefix for all EPiServer configuration elements in our transform file. The following example changes the siteUrl element and the VPP paths for local development:


<epi:site siteId="MySite" xdt:Locator="Match(siteId)" xdt:Transform="SetAttributes">
<epi:siteSettings siteUrl="http://localhost/" xdt:Transform="SetAttributes" />

<epi:add physicalPath="C:\VPP\PageFiles" name="SitePageFiles" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
<epi:add physicalPath="C:\VPP\Global" name="SiteGlobalFiles" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
<epi:add physicalPath="C:\VPP\Documents" name="SiteDocuments" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />


Hope this helps!