The CLI publish command

Version:

The Sitecore publishing plugin includes a publish command. This command publishes Sitecore Items. To install the publishing plugin, run the following code:

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

Usage

You can use the command as follows:

dotnet sitecore publish [options]
Tip

Some Sitecore CLI command examples wrap items names and other strings containing spaces in single quotes for correct interpretation by PowerShell. If you use a different command-line shell, you might have to change single quotes to double quotes.

Options

You can use the following options with the publish command:

OptionRequired?Description
-n, --environment-name <environment-name>OptionalThe Sitecore environment to use. Default: default.
-c, --config <CONFIG>OptionalPath to root sitecore.config directory (default: cwd).
-l, --languages <languages>OptionalComma-separated list of languages to publish. If unspecified, then all languages are published.
-p, --path <path>OptionalSitecore item path or GUID to smart publish. If unspecified, then the full database is published.
-r, --republishOptionalUse republish. If unspecified, then smart-publish is used instead.
-v, --verboseOptionalReport additional diagnostic and performance data.
-t, --traceOptionalReport additional diagnostic and performance data.
-?, -h, --helpOptionalHelp for the command.

Examples

The following are examples of the publish command use:

CommandResult
Attempt to publish from the samples folder:

dotnet sitecore publish
Does not publish Sitecore items and returns the message error: Couldn't resolve a root configuration file (sitecore.json) in the current or any parent directory. Looks like the command may have been executed outside a Sitecore project?
Attempt to publish from the samples folder:

dotnet sitecore publish -c Prototype/
Publishes the Sitecore items from the folder samples.
dotnet sitecore publish -n testEnvPublishes Sitecore items to the environment with the name testEnv.
dotnet sitecore publish -l en-US,en-CAPublishes Sitecore items for only the specified languages (en-US,en-CA).
dotnet sitecore publish -p /sitecore/content/Home/Test ItemPublishes only the item with path /sitecore/content/Home/Test Item.
dotnet sitecore publish -vCreates additional diagnostic and performance data, such as root config path or count of nodes with performance, for example, 73ms (8.1ms/node).
dotnet sitecore publish -tCreates additional diagnostic and performance data, such as FSIndex: Loaded filesystem indexes in, for example, 70ms (9 metadatas) or created package of 1 trees in, for example, 1983ms (9 items; 220.3ms/node).
If you have suggestions for improving this article, let us know!