Why Aren't My Sitecore Roles Syncing Via Unicorn?


Brandon Bruno


January 13, 2020


Why Aren't My Sitecore Roles Syncing Via Unicorn?

Unicorn is a fundamental tool in every Sitecore developer's toolbox, allowing database content to sync across different environments. While Unicorn is primarily used to sync dev content, settings, and configuration items in Sitecore, it can also sync users and roles.

I recently had an issue where user roles were not syncing between environments. Troubleshooting the problem was tricky because - as it turns out - the Unicorn user interface hides some critical information about the configuration of the Unicorn data store.

The Problem

User roles were not syncing in higher environments - during a Unicorn sync, the Foundation.Serialization.Roles configuration reported 0 synced items. The YML files were present on disk and the roleDataStore setting looked to be configured properly. Just to be safe, I double-checked the Physical root path in the Unicorn control panel:

Unicorn control panel for Foundation.Serialization.Roles.

And of course, the corresponding value in the Unicorn Roles configuration:

<roleDataStore type="Unicorn.Roles.Data.FilesystemRoleDataStore, Unicorn.Roles" physicalRootPath="D:\Client\Source\$(layer).$(module)\$(configurationName)" singleInstance="true"/>

The physicalRootPath path above resolves to:


So the roleDataStore path defined in configuration definitely matches what the Unicorn control panel is showing, right? Actually, no - look closer.

The Solution

I spent a lot of time debugging various issues with file paths and folder access. As it turns out, the configured physicalRootPath for the roleDataStore was simply wrong - a . was placed where a \ should have been (subtle!).

So what threw me off? The Physical root path displayed for the Foundation.Serialization.Roles configuration in the Unicorn control panel was not showing me the path configured for the roleDataStore. It was displaying the default targetDataStore that was set up for the other (content) configurations. This was kind of a red herring.

About Unicorn Data Stores

Unicorn has a few different types of commonly used data stores. Each serves the purpose of telling Unicorn where to find serialized YML items on disk, but differ in the types of content being synced. I've also linked the relevant Unicorn source code and examples that demonstrate each data store:

In short, Unicorn's control panel doesn't display the roleDataStore for a configuration's Physical root path, but instead displays the default targetDataStore. If you're debugging sync issues with roles, remember to reference your configuration files directly to verify paths!

Do you have questions, comments, or corrections for this post? Find me on Twitter: @BrandonMBruno