An easy way to create Sitecore config files

Some people find it a bit tricky to write Sitecore config files. It can sometimes be a bit tricky or time consuming to get the element structure correct. Ever found yourself debugging an issue where it turned out the config file wasn’t applied properly due to an element structure mistake?

The XPath Tools plugin, by Uli Weltersbach, for Visual Studio is a great help for creating those config patch files. Here’s a way to create those in a fast and simple way:

Start with a Sitecore config boiler plate:
Sitecore config template

Then grab the expanded Sitecore config file through Sitecore Rocks:
Open Expanded Web.config

Navigate to the section where you want to apply your config change and select “Copy XML structure”. In this example I’ll add a computed field to the default Solr index section:
Copy XML Structure

Then paste it into your config template:
Sitecore config structure

From here on it’s a simple task to just remove the surplus attributes you don’t need, such as database="SQLServer" xmlns:patch… and so on:
Complete patch file

So XPath tool is a small but very helpful tool that makes life just a little bit easier.

You can get the XPath tool from within Visual Studio or download it here, or grab it from GitHub.

Leave a Reply