Sitecore Conditional configs: deploy just 1 package

When deploying Sitecore to your DTAP environment, you will always need a separate set of configuration files per environment.
One solution to accomplish is this, is to use web.config transforms with slowcheetah.
What I personally dislike about this approach, is that you have to create separate builds per environment.

That is why we at eFocus came up with a different approach: conditional configs.
With conditional configs, you create separate config files per environment, and then specify which config file applies to which environment by using filters inside config file itself. The current available filters are machinename and installpath (if you need any other filters, let me know, the current two work for all our environments).
Now you can create a deploy package for you entire sitecore folder, including all configs. The configs will only apply if the filter matches at sitecore startup.

The patch system works exactly like you are used to from the sitecore include configs.
You just have to place them in a separate folder named include-conditional.

Also, we have built in 2 extra config options: files having the name of the rootnode set to “connectionStrings”, will patch your web.config’s connectionstring section
and files with rootnode “mailSettings” will patch your mailsettings section of the web.config.

You enable the conditional configs by either installing the nuget package Efocus.Sitecore.ConditionalConfig or by downloading the source from https://github.com/efocus-nl/efocus.sitecore.conditionalconfigs and include it in your project.
You have to patch your sitecore’s web.config on only one place, you have to place

    

instead of

  

Sample of how your condtional configs in app_config/Include-condtional might look:

< ?xml version="1.0"?>

  
    
    

    
    
    
    
  

As you can see on the rootnode, it has a condition “machinename”. This is a regular-expression, matched against the computer name at sitecore startup.
The other option is, like noted above, to match the installpath:

< ?xml version="1.0" encoding="utf-8"?>

  
  
  

In this case, there are two conditions, they have to match BOTH

Well, that’s all there is to it. If you have an opinion or question, leave a comment