Tailwind Logo

Sitecore CLI Series

CLI

Published: 2022-06-06

The Sitecore CLI is a very useful feature that allows you to control Sitecore from the command line. This series of articles introduces the procedures for setting up a Sitecore CLI environment and related functions.

Sitecore CLI Commands

Basic commands for the Sitecore CLI start with dotnet sitecore. The help file shows the following.

PowerShell
PS C:\projects\sitecoredemo-jp> dotnet sitecore --help
sitecore.cli:
  Sitecore command line tool

Usage:
  sitecore.cli [options] [command]

Options:
  --version         Show version information
  -?, -h, --help    Show help and usage information

Commands:
  login                 Authenticates the CLI to a Sitecore instance
  plugin                Manage plugins commands
  init                  Creates Sitecore configurations in current directory
  index                 working with indexes data
  itemres               Resource Items Package commands
  ser, serialization    Item serialization commands
  publish               Performs a publish operation on all content

PS C:\projects\sitecoredemo-jp>

Login

When executing the login, include the server as shown below. Once executed, the server name and other information is saved in the environment file.

PowerShell
dotnet sitecore login --cm https://cmserver.local/ --auth https://login.local/ --allow-write true

import-export

You can specify the import or export process by specifying push or pull after the dotnet sitecore ser.

PowerShell
dotnet sitecore ser push
dotnet sitecore ser pull

You can also check other processing steps by running Help.

PowerShell
PS C:\projects\sitecoredemo-jp> dotnet sitecore ser --help
serialization:
  Item serialization commands

Usage:
  sitecore.cli serialization [options] [command]

Options:
  -?, -h, --help    Show help and usage information

Commands:
  info            Shows serialization configuration information
  explain         Explains whether an item path is included and why
  pull            Pulls serialized items from Sitecore to disk
  push            Pushes serialized items from disk into Sitecore
  diff            Compares two Sitecore instances
  validate        Checks serialized items for validity and can fix common issues
  watch           Watches item changes in Sitecore and pulls them to disk.
  package, pkg    Create or install packages of serialized items

Tags