Santa

Let’s Talk

We would love to hear from you. Want to know more about
our services or have any questions? Say Hi!

Sitecore Serialization Tools

December 16, 2022
Sitecore Serialization Tools
Mitesh Patel
Mitesh Patel
Technical Head
sitecore-serialization-tools

Sitecore Serialization helps teams of developers who are working on the same solution to sync the database changes between their individual development environments. Serialization is also very useful for when a single developer is working on a solution.

You use serialization to serialize an entire Sitecore database or sometimes a series of items in a database to the text files. Then, you use these text files to transfer this same database or series of items to a different database or a Sitecore solution. Typically, Sitecore Serialization can be used in combination with a source control system to make it easier for the developers to sync the database changes between the local databases that they use for developing the solutions. The source control system also keeps track of the database changes and allows you to compare these changes.

You have three serialization access points in Sitecore. They all use the same general settings in the App_Config\Sitecore\CMS.Core\Sitecore.Serialization.config file.

1. Unicorn

Unicorn is a utility for Sitecore that solves the issue of moving templates, renderings, and other database items between Sitecore instances.

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. 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 always the master copy of everything. Then if you execute the sync page, the merged changes are synced into your Sitecore database.

  • Unicorn installation

  • Install Unicorn. This is as simple as adding the Unicorn NuGet package to your project.

When you install the NuGet package, a README file will come up in Visual Studio with help to get you started.

sitecore-serialization-tools-1
2. TDS

The primary goal of Sitecore TDS was to enable the developers to manage their Sitecore schema (Templates, Layouts, Sub layouts, Taxonomy, and meta-data items) the same way they manage the source code. Over the year, the software development field has built many exceptional for managing and deploying the source code but Sitecore developers were not able to leverage things like Source Control, automated builds and automated deployments for their Sitecore items.

sitecore-serialization-tools-2
3. Sitecore CLI

Sitecore Command Line Interface (CLI) is a tool that you install in a terminal. You can install Sitecore CLI either as a local tool for individual projects or as a global tool for all projects.

It will not provide user interface.

As the name suggests, Sitecore Command Line Interface (CLI) is a command-line tool named Sitecore, and you add subcommands and options to accomplish different tasks.

The Sitecore Command Line Interface is a new tool that was created to improve the Developer Experience with Sitecore 10. And specifically, for usage with serializing Sitecore items.

The CLI tool will receive additional functionality in the future. But for now, it can be used for serialization, creating item packages and for publishing. No license is required, you just have to install it and start using it.

So, on one side we have the CLI to interact with a Sitecore environment.

A big advantage is that you can use these tools to fetch items from a Sitecore website on another environment. So as a developer, we can more easily fetch items from an acceptance environment for example.

  • Sitecore CLI installation

    To install Sitecore CLI as a local project tool:

    1. If you have not already done so, install Sitecore Management Services.

    2. Open a terminal with administrator privileges.

    3. Run the following commands to install Sitecore CLI:

      Copycd <project folder>

      dotnet new tool-manifest

      dotnet NuGet add source -n Sitecore https://sitecore.myget.org/F/sc-packages/api/v3/index.json

      dotnet tool install Sitecore.CLI

  • To initialize your new project, run the following command in your project folder:

    • dotnet sitecore init
  • Install the required Publishing and Serialization plugins:

    • dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization

    • dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Publishing

  • You can check the installed plugins using the dotnet sitecore plugin list command:

  • List of plugins:

    • Sitecore.DevEx.Extensibility.Publishing v.4.0.0

    • Sitecore.DevEx.Extensibility.Serialization v.4.0.0

  • Required command was not provided.

  • Usage:

    sitecore.cli [options] [command]

    • Options:

      --version Display version information

    • Commands:

      login Authenticates the CLI to a Sitecore instance

      publish Performs a publish operation on all content

      ser, serialization Item serialization commands

      init Creates Sitecore configurations in current directory

Difference of unicorn and TDS

The similar functionality between the two is the ability to serialize Sitecore items to disk.

TDS Classic does this but installing a web service into your local site, and pushing/pulling content through it, using a Visual Studio extension UI, and through MS Build. Unicorn changes Sitecore's default Data Provider to use the serialized file on disk (.yml files) as the master copy. It then has its own admin panel for pushing/pulling the item content between disk and Sitecore.

both tools offer a much better process and item management that should be used in development.

Unicorn is a serialization tool, that states in its README.

It is free and open source, and does one thing well

In addition to the above features, Unicorn has these features: -

  • Sync users (Both can Sync Roles, but only Unicorn can sync users).

  • Push Serialized File Changes Automatically to Sitecore - Unicorn Transparent Sync (this is arguably dangerous though)

TDS Classic is commercial product that began as a serialization tool, but became a much larger productivity tool, with many other opt-in features for efficient Sitecore development. New features are continually being added to every release, but here is a (non-exhaustive) list of those built-in features (as up to date with TDS Classic version 5.7). (It's probably best to reach out to Hedgehog directly or check the website/docs for a proper, up-to-date feature list and tool comparison, as I always forget some!)

EXTENSIBILITY

TDS Classic is largely extensible with its features via MS Build, while Unicorn is largely configurable through Sitecore Include configs. Overall, build/deployment scenarios for both products can be customized... both with the ability to utilize custom code and/or third-party modules to be able to do even more than what's offered out of the box.

PERFORMANCE

This is largely subjective, and will differ from project to project, and test to test. For example, on the Habitat demo site, Unicorn Dilithium has been found to be quicker when just syncing item content with no changes, but TDS Classic will out-perform it when syncing from scratch. TDS Classic also halves the Habitat full solution build/deploy (which arguably has more to do with gulp/MS Build than Unicorn/TDS Classic, but factors into how developers work with Sitecore). Performance should probably be a separate discussion, because it can vary so much between each individual machine, each project, each process, and for each available performance 'boost' used by each tool.

COST

Unicorn is free, TDS Classic is a paid product.

Hedgehog offer a free 30-day trial of TDS Classic on the website. Also, licensing costs for TDS Classic vary (from first time purchase, license renewals, bulk purchases, MVP purchases etc.).


YOU MAY ALSO LIKE