Hidden config "include folder" feature in Sitecore
All Sitecore developers knows about
\App_Config\Include - that all
*.config files in that folder is merged into the final Sitecore configuration. They also know that they are loaded in alphabetical order and if you want to overwrite something in the default Sitecore configs you have to make sure it is sorted after the file in question.
However, while working on another personal project I discovered that before merging all files from
/App_Config/Include Sitecore loads and merges any config files existing in
This has actually been the case since Sitecore 7 (at least).
Did you know you can now use Windows environment variables in config files? If not, here's my blog post about it.
I'm wondering why this isn't used by Sitecore for their default config files. I've always wished it was done that way, so we can keep our custom configs cleanly separated from the default ones and always be sure that they are patched afterwards. It would also make upgrades easier and easier to keep track of installed modules.
They could probably take it even further, maybe have modules install configs in a separate folder or something. With all the config files that usually are in a solution today it could probably use a bit more organizing.
There's 145 config files in a clean 8.2 Update-2 install - 245 if you count
Potentially it would also make it more clear for (new) developers that they really shouldn't change anything directly in the default configs but instead patch their changes with a separate config file :)
Anyway, moving forward I might start moving all default Sitecore configs to this folder to keep it cleanly separated from our custom code and installed modules.
Someone on the Sitecore Slack pointed out that another option would be to just move the default config files into
/Include/Base and keep your custom configs in
/Include/Custom which would give the same result of keeping things separated.