Sitecore CLI and SVS

Sitecore CLI and SVS

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??        
No alt text provided for this image

Once done, dotnet-tools.json file will be created in config folder:

No alt text provided for this image

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        
No alt text provided for this image

The CD website opens, enter ID and Passwd:

No alt text provided for this image

When you click on allow the following screen appears:

No alt text provided for this image

On console the screen as below appears:

No alt text provided for this image

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:

No alt text provided for this image

Add the following:

source?https://sitecore.myget.org/F/sc-developer-collection/api/v3/index.json

No alt text provided for this image

In order to bring up the SVS module right click on the solution and click on “Sitecore Module Explorer”

No alt text provided for this image

Now you will be able to see SVS:

No alt text provided for this image

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”

No alt text provided for this image

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.

No alt text provided for this image

Create Module Using CLI:

Create a Json file with name “CLI.module.json” with namespace CLI

No alt text provided for this image

Using VS:

Right click on Modules-->New Modules -->

No alt text provided for this image

SVS Module gets created:

No alt text provided for this image

Now lets add items in content tree:

No alt text provided for this image

How to exclude an item for sync using rules:

First we have to write Include rule, once you write click, then enter the details:

No alt text provided for this image

There are options to exclude . In this example we show how to exclude "Shorts"

No alt text provided for this image
No alt text provided for this image

Right click on SVS and Pull Items:

No alt text provided for this image

Since we have excluded Shorts, you will not be able to see it in Sync options:

No alt text provided for this image

Now we can see the items in the SVS:

No alt text provided for this image

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"

? ? ? ? ? ? ? }

? ? ? ? ? ? ]

? ? ? ? ? }

? ? ? ? ]

? ? ? }        
No alt text provided for this image

?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:

No alt text provided for this image

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:

No alt text provided for this image

We can see the same in SVS as well:

No alt text provided for this image



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

要查看或添加评论,请登录

社区洞察

其他会员也浏览了