Sitecore CLI 4.0 has been launched and with this new features appeared, such as plugins but also bugfixes/improvements.
To install it you need to edit or uninstall/install your old CLI in your solution with the new version.
Don’t forget to install the new Sitecore Management Services into your Sitecore instance Module which you can download from here!!!
The major changes are: Sitecore Roles, Exclude global/module specific fields, Sitecore publishing to specific targets, Sitecore Index plugin and Sitecore Resources plugin.
1. Sitecore Roles Introduced
I was really happy when I saw that from now on you can serialize the sitecore roles with Sitecore Content Serialization, similarly to Unicorn.
To serialize it you just need to extend your module where you want the roles to be serialized, for example the modules with roles:
In the above example, serialization happens from the “extranet” domain with all of the roles following the “Cars*” pattern.
2. Exclude global/module specific fields
With the new release, we have the option of excluding fields from serialization. There are two options:
- Exclude globally from all of the modules
- Exclude just on specific modules
To exclude globally you need to add the configuration to your global sitecore.json file, to exclude locally you need to add it in your module configuration. The exclude configuration is really straightforward, you just need to specify the field ID and a description:
For example, if you want to exclude a field from your entire serialization:
For example, if you want to exclude in a module:
3. Sitecore Publish to specific targets
You have the option from now on to publish to specific targets. From default is the web database. The command line for publishing:
dotnet sitecore publish --targets [target-names]
You have the option of publishing to multiple instances, for example:
dotnet sitecore publish --targets Web1, Web2
4. Sitecore Indexing plugin
The plugin was created to handle indexes.
Commands for the plugin:
4.1 List indexes:
dotnet sitecore index list
4.2 Populate Solr Managed Schema:
dotnet sitecore index schema-populate
4.3 Rebuild Indexes
dotnet sitecore index rebuild -indexes [list of indexes]
Example of the multiple index rebuild command:
dotnet sitecore index rebuild --indexes sitecore_master_index, sitecore_web_index
4.4 View Index statistic
dotnet sitecore index statistic
5. Sitecore Resources plugin
With the plugin you can create a new resource item package based on your Sitecore Contend Serialized items or you have the option of creating resource files based on your serialized items produced by Unicorn.
Command to create resource item package:
dotnet sitecore itemres create --output [output path] --include [modules to include] -- exclude [modules to exclude]
Example of the item resource creation command:
dotnet sitecore itemres create --output "D:\Itemresources\Master.dat" --include Feature.Ships --exclude Feature.Cards --overwrite
Command to create resource item package for Unicorn:
dotnet sitecore itemres unicorn --output [output path] --path [path to unicorn serialization folder]
These were the major changes, use them as much as you can:)
Have a great time coding, see you at my next post! 😀
One thought on “Sitecore Content Serialization Changes with CLI 4.0”