Hi Friends,
You can find quick reference guide for Sitecore CLI Commands to do the following:
- Download the Sitecore CLI
- Install the Plugins
- Push or Pull content To/From Local Environment
- In case of Error while syncing, Use “Validate”
- Publish the item from CLI
Download the Sitecore CLI
dotnet tool install Sitecore.CLI –add-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json | Run the command in the PowerShell (Preferred as Admin) |
Install the Plugins
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Publishing | Install the Plugin for Publishing |
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization | Install the Plugin for Serialization |
dotnet sitecore login –cm https://yoursitecoreinstance.localurl –auth https://yourscidentityserver.localurl –allow-write true | Login to the environment – First time setup |
dotnet sitecore connect –ref xmCloud –cm https://xmcloudcm.localhost –allow-write true -n local | Command to setup the Local environment |
dotnet sitecore connect –ref xmCloud –cm < Your CM Environment URL > –allow-write true -n develop | Command to setup the Develop XM Cloud |
dotnet sitecore login | Use this once the initial setup is complete |
dotnet sitecore –> and you can use multiple options. For Serialization, you should use “ser”.
dotnet sitecore ser ——
Push or Pull content To/From Local Environment
dotnet sitecore ser push -n local -w | Run this command -n is the environment name -w is for What If mode – Details below. |
dotnet sitecore ser push -n local | If you don’t see any error in above command then run the command without the -w. |
dotnet sitecore ser pull -n local -w | Run this command -n is the environment name -w is for What If mode – Details below. |
dotnet sitecore ser pull -n local | If you don’t see any error in above command then run the command without the -w. |
What-If Mode:
I love this option. When running the push or pull add a -w in the command. That will Pseudo run the command. Means, it will run the command and will let you know how many items will be created, updated and deleted. It will NOT update anything. It just gives audit report. If you find any important item updating or deleting, then don’t run the pull or push. Also, The detail is color coded. So it is easy to find deleted items. Example below.
In case of Error while syncing, Use “Validate”
dotnet sitecore ser validate | To see the error in the serialization, run the below command |
dotnet sitecore ser validate –fix | Once you see the error add a new param to fix the error |
Publish the item from CLI
dotnet sitecore publish | Publish the content |
dotnet sitecore publish -n develop | Publish the content to the “develop” environment |
dotnet sitecore publish -l en | Publish the content for the “en” language |