0

What is the benefit of including dependencies in Unicorn Configuration file. In what scenarios actually the dependencies are usefull.

Example:

    <configuration name="Project.Example" description="Example Project" dependencies="Foundation.Print" patch:after="configuration[@name='Foundation.Print']">
      <predicate>

        <include name ="Sitecore.Project.Example.Templates" database="master" path ="/sitecore/templates/Project/Example">
          <exclude childern =" true"/>"
        </include>            

      </predicate>

Foundation.Print is the configuration name given for one of my project/module at Foundation layer

3

As outlined in the release details for Unicorn 3.1 on Kam Figy's blog:

Unicorn configurations may now declare dependency relationships between each other. This is useful for example when one configuration may contain templates and another configuration might contain items based on those templates. With a dependency relationship the dependent configurations are guaranteed to always go first when configurations are synced. Transitive relationships (e.g. A -> B -> C) are supported.

[...]

Dependencies do not force dependent configurations to sync. If config A depends on config B and you choose to sync only config A, B will not be synced. However if you sync both A and B, then B will always sync first due to the dependency.

This is a convenient way to ensure that your configurations will be synced in a logical order. It's certainly more intuitive (and less error-prone) than tweaking the patch:after attributes to enforce order.

If you look at the Habitat demo code, you'll find examples where this used. Notice that patch:after is not used, and that the syntax is flexible and allows specifying multiple dependencies (in a Helix solution, this would logically be the Foundation or Feature projects your module depends upon) or even wildcards.

Foundation.Theming.Serialization.config:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore role:require="Standalone or ContentManagement">
        <unicorn>
            <configurations>
                <configuration name="Foundation.Theming"
                               description="Foundation Theming"
                               dependencies="Foundation.Serialization,Foundation.SitecoreExtensions,Foundation.Assets"
                               extends="Helix.Foundation">
                    <predicate>
                        <include name="Settings" database="master" path="/sitecore/system/settings/Foundation/Theming" />
                    </predicate>
                </configuration>
            </configurations>
        </unicorn>
    </sitecore>
</configuration>

Feature.Metadata.Serialization.config:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore role:require="Standalone or ContentManagement">
        <unicorn>
            <configurations>
                <configuration name="Feature.Metadata"
                               description="Feature Metadata"
                               dependencies="Foundation.*"
                               extends="Helix.Feature">
                    <rolePredicate>
                        <include domain="modules" pattern="^Feature Metadata .*$" />
                    </rolePredicate>
                </configuration>
            </configurations>
        </unicorn>
    </sitecore>
</configuration>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.