Tags

, , , , , ,

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 Siteco­re.CLI –add-­source https:­//s­ite­cor­e.m­yge­t.o­rg/­F/s­c-p­ack­age­s/a­pi/­v3/­ind­ex.jsonRun the command in the PowerShell (Preferred as Admin)

Install the Plugins

dotnet sitecore plugin add -n Siteco­­re.D­­ev­­Ex.E­­x­t­e­ns­­ibi­­li­t­y.P­­ubl­­ishingInstall the Plugin for Publishing
dotnet sitecore plugin add -n Siteco­­re.D­­ev­­Ex.E­­x­t­e­ns­­ibi­­li­t­y.S­­eri­­al­i­z­ationInstall the Plugin for Serialization
dotnet sitecore login –cm https:­­//­y­o­ur­­sit­­ec­o­r­ei­­nst­­an­c­e.l­­ocalurl –auth https:­­//­y­o­ur­­sci­­de­n­t­it­­yse­­rv­e­r.l­­ocalurl –allo­­w-­write trueLogin to the environment – First time setup
dotnet sitecore connect –ref xmCloud –cm https://xmcloudcm.localhost –allow-write true -n localCommand to setup the Local environment
dotnet sitecore connect –ref xmCloud –cm < Your CM Environment URL > –allow-write true -n developCommand to setup the Develop XM Cloud
dotnet sitecore loginUse 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 -wRun this command
-n is the environment name
-w is for What If mode – Details below.
dotnet sitecore ser push -n localIf you don’t see any error in above command
then run the command without the -w.
dotnet sitecore ser pull -n local -wRun this command
-n is the environment name
-w is for What If mode – Details below.
dotnet sitecore ser pull -n localIf 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 validateTo see the error in the serialization, run the below command
dotnet sitecore ser validate –fixOnce 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 developPublish the content to the “develop” environment
dotnet sitecore publish -l enPublish the content for the “en” language