Full Sitecore CLI setup for your project

1.Install Sitecore Management Service to your Sitecore Instance using package installer

2. Install .NET 6 in your system (Skip if already installed)

3.Open PowerShell with admin access and use CD command to project folder

cd <project folder>

dotnet new tool-manifest (it will create dotnet-tools.json in .config folder)

dotnet nuget add source -n Sitecore https://sitecore.myget.org/F/sc-packages/api/v3/index.json

dotnet tool install Sitecore CLI (it will install sitecore CLI and add an entry to dotnet-tools.json)

After successful installation  of Sitecore CLI

use dotnet sitecore init command to initialize your new project (this will create sitecore.json and other files)

Incase of plugin error after above command use dotnet sitecore plugin list 

4.Verify Sitecore CLI installation using dotnet sitecore -h 

5. Log in to a Sitecore instance using below command

dotnet sitecore login --authority https://<sitecore-identity-server> --cm http://<sitecore-instance> --allow-write true --client-credentials true --client-id <client-id>

<sitecore-identity-server>,<sitecore-instance> - Take from IIS Sites
Default Client id is Device or you can remove --client-id <client-id> this parameter.




This will open Sitecore in browser , Log in and grant permission to the Sitecore services. (by this User.json will be edited by your settings)
6.Now create module.json file with below code and edit it by custom requirements.
{
  "namespace": "Feature.Test",
  "references": [ "Foundation.*" ],# this is optional parameter
"tags": [ "TemplateRendering" ],# this is optional parameter "items": { "includes": [ { "name": "templates", "path": "/sitecore/templates/Feature/Test", "allowedPushOperations": "createUpdateAndDelete" }, { "name": "renderings", "path": "/sitecore/layout/Renderings/Feature/Test", "allowedPushOperations": "createUpdateAndDelete" } ] } }
You can add content items path also.
7. Now use Sitecore CLI using 
dotnet sitecore ser push -i  tags:[TemplateRendering] Command.
In this we are pushing modules to our sitecore instance from our project which have[TemplateRendering] tag in it.


Comments