The CLI itemres command

Abstract

Reference for the DevEx CLI itemres command that creates an item package in a resource file with configurable options.

The Sitecore Items as Resources plugin includes an itemres command. This command creates an item package in a resource file with configurable options. To install the Items as Resources plugin, run the following code:

dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.ResourcePackage --version 4.0.0

Note

This command is available from CLI 4.0 or later.

You can use the command as follows:

 sitecore.cli itemres [subcommand] [options]

You can use the following subcommands:

Command

Description

create

Creates a new items and resource package with the specific name format items.{databaseName}.{providedName}.dat.

unicorn

Creates a new items and resource package from unicorn serialization with the specific name format items.{databaseName}.{providedName}.dat.

You can use the following options with the create subcommand:

Option

Required?

Description

-o, --output <OUTPUT>

Required

Package path to output (extension added if not provided).

--overwrite <OVERWRITE>

Optional

Overwrite an existing package.

-i, --include <INCLUDE>

Optional

Include module configurations. Wildcards and multiple values are allowed.

-e, --exclude <EXCLUDE>

Optional

Explicitly exclude module configurations. Wildcards and multiple values are allowed.

-c, --config <CONFIG>

Optional

Path to root sitecore.config directory (default: cwd).

-v, --verbose

Optional

Report additional diagnostic and performance data.

-t, --trace

Optional

Report additional diagnostic and performance data.

-?, -h, --help

Optional

Help for the command.

You can use the following options with the unicorn subcommand:

Option

Required?

Description

-p, --path <INCLUDE>

Required

Path to to unicorn serialization.

-o, --output <OUTPUT>

Required

Package path to output (extension added if not provided). Multiple values allowed.

--overwrite <OVERWRITE>

Optional

Overwrite an existing package.

-c, --config <CONFIG>

Optional

Path to root sitecore.config directory (default: cwd).

-v, --verbose

Optional

Report additional diagnostic and performance data.

-t, --trace

Optional

Report additional diagnostic and performance data.

-?, -h, --help

Optional

Help for the command.

The following are examples of the itemres command use:

Command

Result

sitecore itemres create -o TestPackage

Creates the items.{databaseName}.TestPackage.dat file. The file includes all modules.

sitecore itemres create -o test/TestPackage

Creates the items.{databaseName}.TestPackage.dat file in the test folder. The file includes all modules.

Attempt to create TestPackage with a duplicated name:

sitecore itemres create -o TestPackage

Does not create the package and returns with the following message:

"The output path items.{databaseName}.TestPackage.dat already existed, but Overwrite was false."

Attempt to create TestPackage with a duplicated name:

sitecore itemres create -o TestPackage --overwrite

Creates and overwrites the package.

sitecore itemres create -o TestPackage -i Project.Content.Test

Creates the package and includes only the Project.Content.Test module.

sitecore itemres create -o TestPackage -i Project.Content.Test, Project.Content

Creates the package and includes only the Project.Content.Test and Project.Content modules.

sitecore itemres create -o TestPackage -i *Test

Creates the package and includes only the Project.Content.Test module; found with a wildcard prefix.

sitecore itemres create -o TestPackage -i *Test*

Creates the package and includes only the Project.Content.Test and Project.Content.Test1 modules; found with surrounding wildcards.

sitecore itemres create -o TestPackage -i Project*

Creates package and includes the Project.Content, Project.Content.Test, and Project.Content.Test1 modules; found with a wildcard suffix.

sitecore itemres create -o TestPackage -e Project.Content.Test

Creates package and includes only the Project.Content and Project.Content.Test1 modules; excluding the Project.Content.Test module.

sitecore itemres create -o TestPackage -e Project.Content.Test, Project.Content

Creates package and includes only the Project.Content.Test1 module, excluding the Project.Content and Project.Content.Test modules.

sitecore itemres create -o TestPackage -e *Test

Creates package and includes only the Project.Content and Project.Content.Test1 modules, excluding the Project.Content.Test module with a wildcard prefix.

sitecore itemres create -o TestPackage -e *Test*

Creates package and includes only the Project.Content module; excluding the Project.Content.Test and Project.Content.Test1 modules with surrounding wildcards.

sitecore itemres create -o TestPackage -e Project*

Creates package and excludes the Project.Content, Project.Content.Test and Project.Content.Test1 modules with wildcard suffix.

sitecore itemres create -o TestPackage -i Project* -e Project.Content.Test

Creates package and includes the Project.Content and Project.Content.Test1 modules with a wildcard suffix and also excludes the Project.Content.Test module.

sitecore itemres create -o TestPackage -i Project.Content.Test -e Project.Content.Test

Does not create the package and returns with the following message:

The include and exclude options contain same modules at the same time

Attempt to create TestPackage from the samples folder:

sitecore itemres create -o TestPackage

Does not create the package and returns with the following 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 create TestPackage from the samples folder:

sitecore itemres create -o TestPackage -c Prototype/

Creates the package in the samples folder.

sitecore itemres unicorn -p "testItem" -o "TestPackage

Creates the items.{databaseName}.TestPackage.dat file.

sitecore itemres create -o TestPackage -v

Creates additional diagnostic and performance data, such as root config path or count of nodes with performance, for example, 73ms (8.1ms/node).

sitecore itemres create -o TestPackage -t

Creates additional diagnostic and performance data, such as FSIndex: Loaded filesystem indices in, for example, 70ms (9 metadatas) or created package of 1 trees in, for example, 1983ms (9 items; 220.3ms/node).