Alright let’s address the elephant in the room! Kam Figy is not the creator of Unicorn, Kamruz Jaman is. This post is not mean to sing praises of Unicon or the Kams as we callz it. It is mainly to show how we use Unicorn to build our end to end deployment from a dev machine to the production CD’s using Unicorn for serialization.
If I have not said so before, I love VSTS and Octopus Deploy. I am not a master of either but I got a great deal of experience in the past year setting them up. I will follow up this blog post with Octopus posts but this one is reserved for Unicorn.
Unicorn != TDS && TDS != Unicorn. This has been said multiple times. Each has a few features which are common but they have their own set of features. TDS being that its a paid product has a lot of great features especially to do with deployment, builds etc.
So lets start. First you install Unicorn from NuGet:
Install-Package Unicorn -Version 3.3.2
This installs a set of configs and adds appropriate references to your project. If you plan on serializing roles, you would also need Unicorn.Roles:
Install-Package Unicorn.Roles -Version 3.3.2
By default, Unicorn provides sample configurations. Here are some I use:
I make sure that the config transforms locally point to the local serialization folder outside of the wwwroot on my dev box. This helps a lot in structuring your configs on all the environments. Using Octopus, we set the path for the serialization folder dynamically.
For your deployment:
- Package code and serialization separately in to different Nuget Packages. I use Nuspec files with Octopus Deploy.
- Once code is deployed, make sure you remove the Unicorn.DataProvider.config file from the destination CD/CM so that Unicorn does not serialize on those servers.
- Make sure the serialization folder on the destination system is wiped before your add it via Octopus or any other deployment tool.
- Deploy the serialization Nuget package.
- Use PowerShell to sync Unicorn serialized files automatically as part of your deployment process on the CM instances.
- On CD’s remove the Rainbow.config and Project.Unicron.Serialization.config files.
Here is a sample of the Octopus step of sync Unicorn via PowerShell:
$apppath = $OctopusParameters["sitecore.powershellfolder"] $siteHostName = $OctopusParameters["website.url"] $siteUrl = "$siteHostName/unicorn.aspx" Import-Module $apppath\Unicorn.psm1 Sync-Unicorn -ControlPanelUrl $siteUrl -SharedSecret 'YOURSECREDKEYPLEASEUSEALONGONEANDBEMEEEFRIEND'
Since we deployed this 5 months ago, we have not touched it. We run through a few hundred deploys per week.
From dev to prod, we do not do any manual steps, everything is handled by Octopus and so far we have not yet gotten any Unicorn issues. If you do end up with an odd situation, Kam is reachable on the Sitecore Slack and he is very responsive.
If you have any questions or concerns, please get in touch with me. (@akshaysura13 on twitter or on Slack).