Unicorn is a utility for Sitecore that solves the issue of moving templates, renderings, and other database items between Sitecore instances. This becomes problematic when developers have their own local instances - packages are error-prone and tend to be forgotten on the way to production. Unicorn solves this issue by writing serialized copies of Sitecore items to disk along with the code - this way, a copy of the necessary database items for a given codebase accompanies it in source control.
For basic usage, Unicorn 3 has two moving parts:
- Data provider - The default Sitecore data provider is extended to automatically serialize item changes as they are made to Sitecore. This means that at any given time, what's serialized is the "master copy."
- Control panel - this tool (/unicorn.aspx) is a page that can sync the state of Sitecore to the state stored on disk (respecting presets and exclusions). You do this after you pull down someone else's serialized changes from source control.
Unicorn avoids the need to manually select changes to merge unlike some other serialization-based solutions because the disk is always kept up to date by the data provider. This means that if you pull changes in from someone else's Sitecore instance you will have to immediately merge and/or conflict resolve the serialized files in your source control system - leaving the disk still the master copy of everything. Then if you execute the sync page, the merged changes are synced into your Sitecore database. Unicorn 3 uses the Rainbow serialization engine, which uses some format enhancements that make it far simpler to merge than the Sitecore default format.
Is Unicorn Right For Me?
Unicorn forces all of the merging to be done on the disk, you never have to manually select what to update when you're running a sync operation or remember to write changed items to disk. Unless you have actual collisions, this saves a lot of time because you can take advantage of Git, SVN, TFS, etc to do automerges for you. Unicorn is relatively simple, free and open source, and does one thing well. Use whatever makes you happy :)
Unicorn Features
There are a few special features that Unicorn has that are worth mentioning.
- You can define multiple configurations, which allow you a lot of flexibility: you can serialize items to different places on disk, set up groups that can be synced separately, and override any aspect of Unicorn in each configuration. Configurations may also define dependencies between each other to enforce a hierarchy.
- Using Rainbow gives Unicorn 3 a unique, easy to manage serialization format and hierarchy.
- Unicorn rejects "inconsequential" changes to items. The Sitecore Template Editor likes to make a lot of item saves that change nothing but the last modified date and revision. These are ignored to reduce churn in your source control.
- During a sync operation, Unicorn can detect improperly merged renamed items (e.g. two serialized items with the same ID in different files) and will report that fact as an error.
- Automatic retries are performed in the event of a load failure during a sync, which means that syncing items with a missing template along with the template itself in the same sync session will work correctly.
- Unicorn's logging routines report on exactly what was changed about a deserialized item (changed fields, added/removed versions, moved, renamed, etc)
- The control panel writes all console output - e.g. of a sync - to both the screen and the Sitecore log file. This provides a handy audit trail of what synchronizations did in the event of someone asking where an item went.
- You can use
FieldFilter
s to ignore deserialization and changes to specific fields you don't want to sync. - The automatic serialization cannot be blocked by event disabling code because it runs at a data provider level.
- Content editor warnings are shown for items that Unicorn is controlling.
- You can define custom ways to compare fields, if there are equivalencies that are more complex than string equality
- There are event pipelines that can be used to hook to sync events. These can be used, for example, to auto-publish synced items.
- Transparent syncing allows the data provider to read directly from the serialized items on disk, making them appear directly in Sitecore.
There are also a series of blog posts detailing enhancements to Unicorn 3 (and Rainbow) specifically in greater detail at Kam's blog:
- Unicorn 3: What's New?
- What is Rainbow?
- Rethinking the Sitecore Serialization Format with Rainbow
- Reinventing the Serialization File System with Rainbow
Andrii Snigyr has written a Unicorn Visual Studio Extension that enables syncing from within Visual Studio 2013-2015. This tool is natively supported in Unicorn 3 without any additional installation; enable the Unicorn.Remote.config.disabled
file by renaming it to .config
to enable its APIs.
Development Team
Help and Support
See the Troubleshooting section for some common fixes.
Questions, comments, and feature requests should be submitted on GitHub. You may also check out the #Unicorn Slack channel for more interactive support. Not on Slack yet? Contact us on Twitter and we'll send you an invite.