The CLI serialization command
The Sitecore serialization plugin provides the serialization
command with the short form ser
.
This command handles the serialization of items.
To install the serialization plugin, run the following code:
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization
Usage
You can use the command as follows:
dotnet sitecore serialization [subcommand] [options]
Alternatively, you can use the short form for the command as follows:
dotnet sitecore ser [subcommand] [options]
Subcommands
You can use the following subcommands:
-
The
info
subcommand - shows serialization configuration information. -
The
explain
subcommand - explains whether a content item path is included and why. -
The
pull
subcommand - serializes content items from a Sitecore instance to your file system. -
The
push
subcommand - pushes serialized content items from your file system to a Sitecore instance. -
The
diff
subcommand - compares the content items of two Sitecore instances. -
The
validate
subcommand - checks serialized content items for validity. Can fix common issues with the--fix
argument. -
The
watch
subcommand - monitors changes to content items in a Sitecore instance and automatically serializes the changes to your file system. -
The
package
subcommand - provides additional commands for working packages of serialized items. -
The
package create
subcommand - creates a package of serialized items. -
The
package install
subcommand - installs a package of serialized items in a Sitecore instance.
Some subcommands have additional options or improvements to existing options starting with version 4.0.0, as follows:
-
In version 4.0.0 and later, you can specify excluded fields with the
--exclude
(-e
) option on most subcommands. -
In version 4.0.0 and later, the
push
subcommand supports the--targets
(-pt
) option. -
In version 4.1.0 and later, some subcommands support a
--force
(-fr
) option that forces the operation to continue by skipping error-causing files, throwing a warning instead of an error. The option is available for version 4.1.0 and later. -
In version 4.1.0 and later, the
--include
(-i
) and--exclude
(-e
) options support module tags. The subcommandspush
andpull
also support tags.
The info subcommand
The info
command provides information about how the solution is set up and configured for use as it relates to content serialization.
The information returned by the command includes a list of all serialization module configurations. For every serialization module configuration, the information includes:
-
Module name.
-
Module description.
-
Item subtrees with name and path.
You can use the following options with the info
subcommand:
Option |
Required? |
Description |
---|---|---|
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Path to root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Display developer help and usage information about the command. |
The following is an example of using the info
subcommand:
Command |
Result |
---|---|
RequestResponse
|
RequestResponse
|
The explain subcommand
You can use the explain
to provide detailed serialization-related information on a given Sitecore item path and an optional database.
The subcommand provides the following:
-
Item path is within the scope of any serialization modules.
-
Related allowed operations for the given item path.
-
Path to the serialization
Module.json
set up for the given path.
You can use the following options with the explain
subcommand:
Option |
Required? |
Description |
---|---|---|
|
Yes |
Item path to explain. |
|
No |
Database of the item path to explain. Default: |
|
No |
Path to root |
|
No |
Write some additional diagnostic and performance data. |
|
No |
Display developer help and usage information about the command. |
The following are examples of using the explain
subcommand:
Command |
Result |
---|---|
Explain a path not included in any module configuration: RequestResponse
|
RequestResponse
|
Explain a path included in a module configuration: RequestResponse
|
RequestResponse
|
The pull subcommand
The pull
subcommand takes items from Sitecore, serializes them, and stores them as .yml
files on a given file system path. The subcommand uses Module.json
files to determine what items are included in the serialization process. During the pull operation, the serialization engine evaluates existing serialized items on disk and performs a deep comparison of the same items in the source Sitecore instance.
This command requires elevated permissions.
You can use the following options with the pull
subcommand:
Option |
Required? |
Description |
---|---|---|
|
No |
Named Sitecore environment to use. Default: |
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
List the commands involved in the operation without running them. Note See the video Sitecore CLI and the 'what-if' flagfor more information on the |
|
No |
Skip filesystem integrity validation before syncing. |
|
No |
Path to root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Show a warning instead of an error. Skip the item causing the warning and continue serialization. |
|
No |
Use debug (un-hashed) item signatures to diagnose hash mismatches. Much slower. |
|
No |
Display developer help and usage information about the command. |
The following are examples of using the pull
subcommand:
Command |
Result |
---|---|
RequestResponse
|
All Sitecore items from the configurations are serialized on disk. |
RequestResponse
|
All Sitecore items from the ModuleA and ModuleB configurations are serialized on disk. |
RequestResponse
|
All Sitecore items from the modules tagged as tagA and tagB configurations are serialized on disk. |
RequestResponse
|
All Sitecore items from the modules tagged as tagA, tagB, and ModuleA configurations are serialized on disk. |
The push subcommand
The push
command takes items serialized as .yml
files on disk and pushes them to a destination Sitecore instance. The push operation uses serialization Module.json
files to determine the items included in the serialization process. During the push operation, the serialization engine evaluates existing serialized items on the file system and performs a deep comparison of the same Items in the source Sitecore instance.
This command requires elevated permissions.
You can use the following options with the push
subcommand:
Option |
Required? |
Description |
---|---|---|
|
No |
Named Sitecore environment to use. Default: |
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
List the commands involved in the operation without running them. |
|
No |
Skip file system integrity validation before syncing. |
|
No |
Path to root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Show a warning instead of an error. Skip the item causing the warning and continue serialization. |
|
No |
Use debug (un-hashed) item signatures to diagnose hash mismatches. Much slower. |
|
No |
Publish synced items. Not recommended to use with Publishing Service due to performance drop. |
|
No |
List of targets database to publish. Blank publishes to the |
|
No |
Display developer help and usage information about the command. |
The following are examples of using the push
subcommand:
Command |
Result |
---|---|
RequestResponse
|
All Sitecore items from the configurations are pushed to the Sitecore instance. |
RequestResponse
|
All Sitecore items from the ModuleA and ModuleB configurations are pushed to the Sitecore instance. |
RequestResponse
|
All Sitecore items from the modules tagged as tagA and tagB configurations are pushed to the Sitecore instance. |
RequestResponse
|
All Sitecore items from the modules tagged as tagA, tagB, and ModuleA configurations are pushed to the Sitecore instance. |
The diff subcommand
The diff
subcommand compares serialization items between a source Sitecore instance and a destination Sitecore instance. The operation uses serialization Module.json files to determine the items included in the comparison process. During the diff command, the serialization engine performs a deep comparison of paths and items in the source Sitecore instance and the destination Sitecore instance.
This command requires elevated permissions in both source and target environments.
You can use the following options with the diff
subcommand:
Option |
Required? |
Description |
---|---|---|
|
Yes |
Named Sitecore endpoint to use as a source for comparison. |
|
Yes |
Named Sitecore endpoint to use as a destination for comparison. |
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Item path to compare (instead of include/exclude). |
|
No |
Source database (when used with |
|
No |
Destination database (when used with |
|
No |
Apply the detected differences to the destination. |
|
No |
Path to the root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Display developer help and usage information about the command. |
The following is an example of using the diff
subcommand:
Command |
Result |
---|---|
RequestResponse
|
RequestResponse
|
The validate subcommand
The validate
subcommand ensures file system integrity of serialized items and paths. Additionally, by using the --fix (-f)
argument option flag, the command can attempt to auto-correct identified issues. The subcommand evaluates all serialized paths and subtrees on the file system configured in serialization Module.json
files and performs the following checks on the file system:
-
Invalid physical path.
-
Orphaned parent ID.
-
Non-included item.
-
Empty folder.
-
Duplicate item ID.
-
Non-unique path.
For more information, see Validate serialized content items.
You can use the following options with the validate
subcommand:
Option |
Required? |
Description |
---|---|---|
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Execute possible fix operations when validating the serialized items. Important Using the |
|
No |
Path to the root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Display developer help and usage information about the command. |
The following is an example of using the validate
subcommand:
Command |
Result |
---|---|
RequestResponse
|
RequestResponse
|
RequestResponse
|
RequestResponse
|
The watch subcommand
The watch
subcommand monitors changes to content items in a Sitecore instance and automatically serializes the changes to your file system.
This command requires elevated permissions.
You can use the following options with the watch
subcommand:
Option |
Required? |
Description |
---|---|---|
|
No |
Named Sitecore environment to use. Default: 'default'; |
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Skip pulling data from Sitecore before starting the watcher. |
|
No |
Continue watching files if they change. Important Using this option can result in tree corruption if the underlying state is changed. Use this option only if some other program touches serialized files that are not changing. |
|
No |
Show a warning instead of an error. Skip the item causing the warning and continue serialization. |
|
No |
Path to the root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Display developer help and usage information about the command. |
The following is an example of using the watch
subcommand:
Command |
Result |
---|---|
RequestResponse
|
RequestResponse
|
The package subcommand
The package
subcommand (short form pkg
) provides additional subcommands for package specific operations, as follows:
Subcommand |
Description |
---|---|
|
Creates a new serialized item package. |
|
Install an existing item package to Sitecore. This command requires elevated permissions. |
You can use the following options with the package
subcommand:
|
Display developer help and usage information about the command. |
The package create subcommand
The package create
subcommand creates a new serialized item package.
You can use the following options with the package create
subcommand:
Option |
Required? |
Description |
---|---|---|
|
Yes |
Path for placing the package after creation. If you do not provide an extension, it is added for you. |
|
No |
Allow overwriting an existing package. |
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. From version 4.1.0 and later, |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Path to the root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Display developer help and usage information about the command. |
The following is an example of using the package create
subcommand:
Command |
Result |
---|---|
RequestResponse
|
A package was created at the specified |
Serializing a module with roles: RequestResponse
RequestResponse
|
Output: RequestResponse
|
The package install subcommand
The package install
subcommand installs an existing item package to Sitecore.
This command requires elevated permissions.
You can use the following options with the package install
subcommand:
Option |
Required? |
Description |
---|---|---|
|
Yes |
Path to the package to install. |
|
No |
Identity authority for the environment, such as identity server or AAD tenant URL. |
|
No |
Sitecore content management hostname to connect to. |
|
No |
The OAuth ClientID to send. Defaults to |
|
No |
The OAuth ClientID to send. Defaults to |
|
No |
Named Sitecore environment to use. Default: |
|
No |
List the commands involved in the operation without running them. |
|
No |
Specify module configurations to include. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Specify module configurations to exclude explicitly. Supports module name, tags. Wildcards and multiple values are allowed. |
|
No |
Path to root |
|
No |
Write additional diagnostic and performance data. |
|
No |
Write additional diagnostic and performance data. |
|
No |
Publish synced items. Because of performance concerns, we recommend you avoid using this option with the Publishing Service. |
|
No |
Displays developer help and usage information about the command. |
The following is an example of using the package install
subcommand:
Command |
Result |
---|---|
RequestResponse
|
The package |