Sitecore Conditional configs 2.0

I just pushed an update for conditional configs to nuget and github. This new release contains 3 new features.

The first new feature is that you can now set condition-* attributes on any sitecore config file! In the application’s prestart event, the module scans all .config files in /App_Config/Include for a matching condition- attribute. If the attribute is there, and it doesn’t match the current environment, the file is made hidden, if it matches the hidden flag is removed from the file. Hidden config files are skipped by Sitecore by default.

The second new feature is that in the same startup event, the module scans for config files matching the pattern *.config.{GUID}, ie myconfig.config.d50f2217-de81-4265-b365-95a4c72c928b. These files are created if you install an .update package (generated by sitecore courier for example) containing .config files. The default sitecore package installer (used by sitecore ship for example) does not overwrite config files if the hash of the existing file doesn’t exactly match the version on the environment you created the update file from. If such a file is found, it replaces the origingal config file with this new file. (TDS packages also do this same process in a post-install event).

The third new feature feels a bit odd, but is very usefull for Sitecore 8. In sitecore 8 there are loads of config files that are not needed on a CD environment (eg all the ExperienceAnalytics aggregation stuff). With conditional configs, you can now place config files in App_Config\Exclude specifying wich config files to exclude on a certain environment. A sample of such an exclude file can be found on github. If an exclude file is found for the current enviroment, all files specified in this config file will be marked hidden.

Leave a Reply

Your email address will not be published. Required fields are marked *