Hiding XDT Transforms from Sitecore

Sitecore ships with a very useful web.config patching feature that allows everything within the element in the configuration file to be modified and extended. It is a best practice recommendation not to modify the web.config file directly but instead use customised configuration files located within the App_Config\Include folder to overlay the modifications that your solution requires.

Rather that regurgitate information on how to use the web.config patching mechanism I’ll suggest instead that you start with John West’s post All About web.config Include Files with the Sitecore ASP.NET CMS for a definitive way into this subject.

web.config transform files

web.config transform files

Developers working with ASP.NET web applications outside of the Sitecore ecosystem are likely to be performing their web.config transformations using Microsoft’s XDT transform syntax. The popularity of the XDT engine is such that it has recently be issued as a NuGet package so that it can be shipped with third-party products. Whilst on the subject of XDT transforms it would be worth pointing out the Slow Cheetah Visual Studio extension for those new to the area. This package enables you to transform your web.config or any other XML file based on the build configuration and preview the outcome – simply invaluable.


Unfortunately the two transformation mechanisms do not always play well together especially if you are developing in the web root. At a recent Sitecore User Group meeting one of the presenters spoke about problems he had encountered when trying to use XDT transforms on configuration files located within the App_Config\Include folder. 

Fortunately there is a simple workaround to this problem. The LoadAutoIncludeFiles method of the Sitecore.Configuration.Factory class gets called to bring in the configuration patch files. This method includes the following logic:


As you can see the config patcher skips over any .config files that have the hidden attribute set. You can use this behaviour to prevent configuration files that contain XDT transforms from being processed by the Sitecore patching mechanism.


3 thoughts on “Hiding XDT Transforms from Sitecore

  1. Thanks, this was really helpful. I ended up creating a pre-build script that sets all the attributes so everyone can build the solution after checking it out and the attributes will be correct.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s