Sitecore CLI and SVS
Phaneendra Kumar Tolety
Composable architect |Sitecore| Contentstack| Technical Manager at Capgemini| TOGAF|PMP| Technical Architect | SAFe Architect | Techno Functional | Project Management| Retail | Food Retail | Oil and Gas Upstream
SVS and CLI
In this blog we will go through the content serialization using?Sitecore 10 and VS2019
The traditional way to serialize the content is by using
1.?????TDS which is licensed
2.?????Unicorn
Now with the Sitecore 10 and VS2019, Sitecore introduced new feature called SVS( Sitecore for Visual Studio) and CLI (Sitecore command line interface). It has the power and features of both TDS and Unicorn. CLI is more at the command line which doesn’t require any license whereas SVS is integrated with VS and requires TDS licence. However both of them perform the same functionality and have the ability to Push, Pull etc.
To explain it, I have setup the Containers for Helix-Basic-ASPnercore. You can download and set it up from : ?https://github.com/Sitecore/Helix.Examples
While setting up the above mentioned solution, the CLI setup is done automatically. Here are the steps to setup manually:
Setting Up the CLI:
Run the following command in Admin mode in the project folder:
dotnet new tool-manifest
dotnet tool install Sitecore.Cli -g --version 2.0.0 --add-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json??
Once done, dotnet-tools.json file will be created in config folder:
Now let's login to the sitecore by using the following command from project folder:
dotnet sitecore login --auth https://<identity.authority> --cm https://
<sitecore.backend.instance> --allow-write true
The CD website opens, enter ID and Passwd:
When you click on allow the following screen appears:
On console the screen as below appears:
Setting up SVS:
The first pre-requisite is to install TDS. You can download a trail version from https://www.teamdevelopmentforsitecore.com/
Download the SVS from https://www.teamdevelopmentforsitecore.com/ and install
Once installation is done:
Add the following:
source?https://sitecore.myget.org/F/sc-developer-collection/api/v3/index.json
In order to bring up the SVS module right click on the solution and click on “Sitecore Module Explorer”
Now you will be able to see SVS:
Starting serialization:
Create modules for sterilization:
..helix-basic-aspnetcore\src
In the above path create a folder called “Learning”
In the above folder create 2 folders “CLI” and “SVS”
Open the sitecore.json which is present in the root folder. Which looks as below. The highlighted portion lets us know in which path the system looks for the content. We have to change it depending on the path where the module.json files are present.
领英推荐
Create Module Using CLI:
Create a Json file with name “CLI.module.json” with namespace CLI
Using VS:
Right click on Modules-->New Modules -->
SVS Module gets created:
Now lets add items in content tree:
How to exclude an item for sync using rules:
First we have to write Include rule, once you write click, then enter the details:
There are options to exclude . In this example we show how to exclude "Shorts"
Right click on SVS and Pull Items:
Since we have excluded Shorts, you will not be able to see it in Sync options:
Now we can see the items in the SVS:
Sync using CLI:
Add Include and Ignored options in “CLI.module.json” :
Weare going to use "Winter_Products" CLI Sync.
"items":
? ? ? ? "includes": [
? ? ? ? ? {
? ? ? ? ? ? "allowedPushOperations": "createUpdateAndDelete",
? ? ? ? ? ? "name": "CLI Include",
? ? ? ? ? ? "path": "/sitecore/content/Basic Company/Home/Products/Winter_products",
? ? ? ? ? ? "scope": "itemAndDescendants",
? ? ? ? ? ? "rules": [
? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? "path": "/Winter_Lotion",
? ? ? ? ? ? ? ? "scope": "ignored"
? ? ? ? ? ? ? }
? ? ? ? ? ? ]
? ? ? ? ? }
? ? ? ? ]
? ? ? }
?Run the command: “ dotnet sitecore ser pull -w”
Now we can see all the items that are present in the content tree in the defined path:
Now lets rung the command to synchronize the items: ?"dotnet sitecore ser pull -i CLI"
Here we are instructing to take the items from CLI module only:
We can see the same in SVS as well:
The video for the above implementation is present at : https://youtu.be/28LMeS4L3_c
Here is the video to setup containers on your local: https://youtu.be/VnP41GqD6rA