August 11, 2016

Sitecore Config Transforms - Use Replace instead of Remove

By: Craig Taylor
August 11, 2016

Sitecore Config Transforms - Use Replace instead of Remove

I love config transforms.  I love being able to have a single file that can be transformed for any number of my build destinations.  It's much, much better than trying to maintain separate config files for each destination.  Many times, I have config files that should *only* exist on either a CM or CD server.  Originally, I used the "Remove" method to remove the entire contents of a config file like so:


While it doesn't technically break anything, it leads to errors in the logs on Sitecore startup that complain about "Reader is in incorrect state":


The fix is actually really easy.  Instead of removing the entire "sitecore" node in the file, just replace it:

Now Sitecore be all happy.


1 comment: