Skip to content
Sitecore config reader that supports specifying dependency on other config files.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
nuget
src
.gitattributes
.gitignore
LICENSE.md
NuGet.config
README.md
build.cake
build.ps1

README.md

Sitecore Dependency Config Reader

AppVeyor NuGet Analyzer

By default Sitecore patches config files in the /App_Config/Include folder alphabetically, which means if you need to make sure your file is patched after a specific default Sitecore config, then you need to make sure it is sorted after. This is commonly done by prepending one or more z's, e.g. z.MySettings.config.

I was wondering if it would be a better solution to be able to specify dependencies on other configs instead.

Requirements

This config reader require Sitecore 8.1.160302 (8.1 Update-2) or higher.

This is where they moved the logic from Sitecore.Configuration.Factory to Sitecore.Configuration.ConfigReader and made the class methods virtual so it's possible to override parts of the logic.

Installation

Just install the NuGet package Additio.Sitecore.DependencyConfigReader and it will transform your Web.config to replace the default Sitecore ConfigReader with this one.

If your Web.config is not in the same project, you will have to manually replace the value.

<!-- Web.config -->
<configuration>
  <configSections>
    <!-- Replace the type of this with 'Additio.Configuration.DependencyConfigReader, Additio.Configuration' -->
    <section name="sitecore" type="Sitecore.Configuration.ConfigReader, Sitecore.Kernel" />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, Sitecore.Logging" />
  </configSections>

  <!-- ... -->
</configuration

Usage

You add dependencies for your config by adding a dependencies attribute to the root element configuration with the name of the file you are depending on - with or without the .config at the end.

<!-- You don't have to include '.config' (but you can) -->
<configuration dependencies="Sitecore.Analytics">
<configuration dependencies="Sitecore.Analytics.config">

<!-- Wildcard matching (supports '?' and '*') -->
<configuration dependencies="Sitecore.*">

<!-- For files in sub folders specify the relative path (relative to '/App_Config/Include') -->
<configuration dependencies="CES/Sitecore.CES">

<!-- You can specify multiple dependencies by separating them by either ',', ';' or '|' -->
<configuration dependencies="Sitecore.Speak.*, Sitecore.Publishing.*">
You can’t perform that action at this time.