andresvillenas/Sitecore.Extensions

View on GitHub
Sitecore.Extensions/App_Config/Include/Unicorn/Unicorn.CustomSerializationFolder.config.example

Summary

Maintainability
Test Coverage
<!--
    This is an example of how to configure Unicorn to override the location on disk to store the serialized items.

    If used, this should be present on all environments where Unicorn is active (usually all but CD).
    
    NOTE: this config file contains several examples. It should not be activated without selecting the mode you wish to use 
    (and in some cases not activated at all if patching a config level path)
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <unicorn>
            <!--
                There are three ways you can set the root path:
                * Per-configuration
                * Using an abstract base configuration with variables
                * For all configurations that do not define something else
                
                All of the options rely on patching the target data store.
                The target data store is where we write serialized items to.

                Note the target data store's rootPath can be any of:
                Absolute filesystem path, e.g. c:\foo\bar
                Web-root-relative path, e.g. ~/data/serialization or ~/../out-of-root-serialization
                Data-folder-relative path, e.g. $(dataFolder)\serializedItems
                A path using a custom sc.variable-defined configuration var, e.g. $(sourcePath)\Feature\Foo

                DO NOT SHARE A ROOT PATH BETWEEN CONFIGURATIONS.
                They can clobber each other's folders. You may inject the name of the current
                configuration as a variable with $(configurationName).
            -->

            <!--
                EXAMPLE: Per-configuration
            -->
            <configurations>
                <configuration name="I Have a Custom Storage Path">
                    <targetDataStore physicalRootPath="c:\MyConfiguration" />
                </configuration>
            </configurations>

            <!--
                EXAMPLE: Abstract base configuration to use conventions
            -->
            <configurations>
                <!-- Setup the convention using the HelixConventionVariablesReplacer (inheriting config must be named Layer.Module) -->
                <configuration name="Helix" abstract="true">
                    <targetDataStore physicalRootPath="$(sourceFolder)\$(layer)\$(module)\serialization\$(moduleConfigName)" />
                </configuration>
                
                <configuration name="Foundation.MyModule.Content" extends="Helix">
                    <!-- 
                        This configuration will now be placed at $(sourceFolder)\Foundation\MyModule\serialization\Content (variables expand at the inheriting config)
                        
                        The same trick works great on predicate paths (e.g. '/sitecore/templates/$(layer)/$(module)')
                    -->
                </configuration>
            </configurations>

            <!--
                EXAMPLE: Change the global defaults for all configs
            -->
            <defaults>
                <!--
                    VERY IMPORTANT: THIS CONFIG MUST LOAD AFTER THE REGULAR UNICORN CONFIGURATION TO PATCH THE DEFAULTS
                    Sitecore config patch files load in alphabetical order, followed by folders.
                    So either place this in App_Config/Include/Unicorn, or a folder that loads after that like 'zSite'
                    -->
                <targetDataStore>
                    <patch:attribute name="physicalRootPath">c:\path-to-source\Unicorn\$(configurationName)</patch:attribute>
                </targetDataStore>
            </defaults>
        </unicorn>
    </sitecore>
</configuration>