All Articles

Sitecore Content Serialization (SCS) - Commands explained - info, and explain

If you want to know more about Sitecore Serialization commands, Refer my previous blog post here.

Serialization commands

In this article, I explain the info, and explaincommands in the Sitecore Content Serialization(SCS) module.

1723041205697

Module configuration

To use these commands let’s first set up some example modules in our solution.

So, I alter the sitecore.json in the below manner:

{
  "$schema": "./.sitecore/schemas/RootConfigurationFile.schema.json",
  "modules": [
    "src/Foundation/*/code/*.module.json",
    "src/Feature/*/code/*.module.json",
    "src/Project/*/code/*.module.json"
  ],
  "plugins": [
    "Sitecore.DevEx.Extensibility.Serialization@5.2.113",
    "Sitecore.DevEx.Extensibility.Publishing@5.2.113",
    "Sitecore.DevEx.Extensibility.Indexing@5.2.113",
    "Sitecore.DevEx.Extensibility.ResourcePackage@5.2.113",
    "Sitecore.DevEx.Extensibility.Database@5.2.113"
  ],
  "serialization": {
    "defaultMaxRelativeItemPathLength": 100,
    "defaultModuleRelativeSerializationPath": "serialization",
    "removeOrphansForRoles": true,
    "removeOrphansForUsers": true,
    "continueOnItemFailure": false,
    "excludedFields": []
  },
  "settings": {
    "telemetryEnabled": true,
    "cacheAuthenticationToken": true,
    "versionComparisonEnabled": true,
    "apiClientTimeoutInMinutes": 5
  }
}

Notice that I have added the Foundation, Feature, & Project layer folders in the modules.

The above configuration will search for module.json file in all the Foundation, Feature, & Project level projects.

Let’s add a few module configuration files.

Foundation.MyFoundation

{
  "namespace": "Foundation.MyFoundation",
  "items": {
    "includes": [
      {
        "name": "templates",
        "path": "/sitecore/templates/Foundation/MyFoundation"
      },
      {
        "name": "renderings",
        "path": "/sitecore/layout/Renderings/Foundation/MyFoundation"
      }
    ]
  }
}

Feature.MyFeature

{
  "namespace": "Feature.MyFeature",
  "items": {
    "includes": [
      {
        "name": "templates",
        "path": "/sitecore/templates/Feature/MyFeature"
      },
      {
        "name": "renderings",
        "path": "/sitecore/layout/Renderings/Feature/MyFeature"
      }
    ]
  }
}

1. info command

The info command displays all the modules included in your configuration.

1723041964211

To display all the modules configured in your solution. Run the below command:

dotnet sitecore ser info

This will display all the modules configured in your solution.

1723042524456

2. explain command

The explain command is used to check which module a particular item belongs to. It can be very useful in cases where, you want to check:

  • If an item belongs to a particular module, if yes, then which one
  • If the item is already configured to be serialized

You can then use this information to either perform pull/push on a specific module, or create a new module for the item.

e.g. When the item is included in a module:

1723044393124

e.g. When the item is not part of any configured module:

1723044442234

You can check all my posts related to Sitecore Content Serialization here.

Published Aug 7, 2024

Sitecore MVP Technology 2024-23. Web Developer with rich experience in Sitecore and ASP.NET MVC.