Using config transforms with EPiServer

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


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

Estimated read time : 3 minutes

Jump to

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="http://schemas.microsoft.com/XML-Document-Transform">

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:episerver>

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

<epi:virtualPath>
<epi:providers>
<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)" />
</epi:providers>
</epi:virtualPath>

<epi:episerver>

Hope this helps!