Let’s Talk

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

How to install and configure Sitecore CLI?

February 09, 2023
How to install and configure Sitecore CLI?
Keyur Garala
Keyur Garala
Sitecore Certified Solutions Architect

Serialization is used to serialize an entire Sitecore database or sometimes a series of items in a database to the text files. You then have to use these text files for transferring this database, or a series of items in another database.

Typically, the Sitecore serialization is 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 are using for development.

The source control system also keeps a track of the database changes and allows you a chance to compare the different changes within the database.

There are many tools available that provide Sitecore Serialization for content management in different types of machines and environments.

  1. TDS



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.

Below, we are going to discuss in detail the Sitecore CLI.

Sitecore CLI

The Sitecore Command Line Interface is a tool that you have to install in a terminal. You can install Sitecore CLI either as a local tool for your individual projects or as a global tool for all of the projects. It will not provide you with a user interface.

As suggested by the name itself, the Sitecore Command Line Interface is a command-line tool named Sitecore and you can add subcommands and options to it for accomplishing different tasks. The Sitecore CLI is a new tool created for improving the developers’ experience with the version Sitecore 10.

This tool can also specifically used with serializing Sitecore items, creating packagaes, and for publishing. No license is required for this, all you have to do is install it and you will be able to start using it.

A major advantage to this is that you can use these tools for fetching items from a Sitecore website on another environment. As a developer, we can more easily fetch the items from an acceptance environment. For example:

Sitecore CLI installation

Follow the below given steps for installation:

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

  2. Open a terminal that comes with administrator privileges.

  3. Go to the project folder and then run the below commands

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

  • To verify that the Sitecore CLI works, go to your project folder in a terminal and type

    dotnet Sitecore –version


    Currently I am using 4.2.0.

To make use of the Sitecore CLI, login is required and there are two ways through which you can verify the user:

  1. Using an interactive user login

  2. Using a non-interactive client login

1) Use an interactive user login

Please run the below commands in the console:

Command: dotnet Sitecore login –authority https://<Sitecore identity server> –cm http:// <Sitecore instance> –allow-write true

Once you fire up the above given command, it will open up a login screen in the browser.

how-to-install-and-configure-sitecore-cli-2 how-to-install-and-configure-sitecore-cli-3 how-to-install-and-configure-sitecore-cli-4

2) Use a non-interactive client login

To enable the non-interactive client login using the client credential flows with your Sitecore instance, you must add the additional configurations to your identity server and to the content management instances.

To configure a non-interactive client login:

  1. On the Sitecore Identity Server, in the Config/folder, create a new file named Sitecore.IdentityServer.DevEx.xml containing the following:

  2. Name the <CliServerClient> element anything that you want.

  3. In the <ClientId> element, enter the unique ID of your client.

  4. In the <ClientSecrets> element, create a <ClientSecret1> element containing the secret of your client.

  5. Now save the Sitecore.IdenityServer.DevEx.xml file.

  6. On the Sitecore Content Management server, in the App_Config/Include/ folder, create a file named Sitecore.Owin.Authentication.ClientCredentialsMapping.config that contains the following:

  7. In the <claim name="client_id"> element, in the value attribute, enter the unique ID of your client.

  8. Check your SQL Membership provider in the web.config file. If the solution has the requiresUniqueEmail attribute set to true, add the following configuration line to the Sitecore.Owin.Authentication.ClientCredentialsMapping.config file:

  9. Save the Sitecore.Owin.Authentication.ClientCredentialsMapping.config file.

  10. Restart the Sitecore Identity Server and the Content Management roles.

  11. Recycle the Sitecore Identity Server application pool.

  12. Validate your configuration by performing the client login procedure.

    Command: dotnet sitecore login --authority https://<sitecore-identity-server> --cm http://<sitecore-instance> --allow-write true --client-credentials true --client-id <client-id> --client-secret <client-secret

After login, you are ready to serialize (push, pull) and publish the database via the below commands.


For serializing any Sitecore items, you can install and configure Sitecore CLI by following the above-given steps.