Upgrading Sitecore CLI for Developers in Local Environments

Upgrading Sitecore CLI for Developers in Local Environments

Pipelines are a great illustration, and how Sitecore items flow from development to production is a critical process to keep things moving.

When we upgraded to Sitecore 10.2, Sitecore CLI was embraced as the new development workflow and deployment tool.  Sitecore CLI promotes Sitecore items the development team builds as part of the CMS.  Below are some of the workings of how we used Sitecore CLI.  Many steps are excluded for brevity...

What is highlighted where Sitecore CLI is used:

  1. Serialization Validate dotnet sitecore ser validate
  2. Serialization Push dotnet sitecore ser push
  3. Serialization Publish dotnet sitecore publish

Plugins depended on 4.1.1, and we needed to go to Sitecore CLI 5.1.25 as the sitecore.json set these versions:

"plugins": [
    "Sitecore.DevEx.Extensibility.Serialization@4.1.0",
    "Sitecore.DevEx.Extensibility.Indexing@4.1.0",
    "Sitecore.DevEx.Extensibility.ResourcePackage@4.1.0",
    "Sitecore.DevEx.Extensibility.Publishing@4.1.0"
  ],

And dotnet-tools.json has the reference to 4.1.0

{
  "tools": {
    "sitecore.cli": {
      "version": "4.1.0",
      "commands": [
        "sitecore"
      ]
    }
  }
}

Updating the tool and the plugins was the easy part.

First, we need to make sure we meet our dependency on .NET Core 6, so we run:

dotnet --version

If we are at least 6.0, we can move forward with upgrading.  Most developers may have this by default on their workstations if they install a later version of Visual Studio.  If you need to, pick up the appropriate version here: https://dotnet.microsoft.com/en-us/download/dotnet/6.0.

Now we can proceed with upgrading the tool:

dotnet tool install Sitecore.CLI --version 5.1.25
https://sitecore.myget.org/feed/sc-packages/package/nuget/Sitecore.Cli

Then update sitecore.json to use the correct versions of the plugin:

"plugins": [
    "Sitecore.DevEx.Extensibility.Serialization@5.1.25",
    "Sitecore.DevEx.Extensibility.Indexing@5.1.25",
    "Sitecore.DevEx.Extensibility.ResourcePackage@5.1.25",
    "Sitecore.DevEx.Extensibility.Publishing@5.1.25"
  ],

Finally, we need to install the Management Services package on the Sitecore instance that matches the version we are updating to: https://dev.sitecore.net/Downloads/Sitecore_CLI.aspx.

If you have Sitecore running under IIS, then Sitecore Package is the way to go. Download the package under Sitecore Management Services Module ZIP Package and install it into Sitecore.

From here, we should be able to complete the following:

dotnet sitecore ser push --what-if

--what-if is excellent if you want to see what happens without doing anything.

If everything goes well, then you should have some success messages in green such as:

[master] Discovered 3 changes after evaluating 286 total items.

But here is where things get tricky.  If you are a good developer and want the rest of your team to use the latest and greatest, you want to ensure you test.  So you publish your Visual Studio solution and test Sitecore CLI...

Broken!

The Sitecore Management Service version of the environment this Sitecore CLI operates with is outdated...

After going back through the previous steps and double-checking, the upgrade was at a loss.  The message needed to be more evident regarding where the issue was occurring.  But, the clue was when the project was published in Visual Studio.

For us, it is more challenging than looking at one project.  We have at least 20+ projects in the Visual Studio solution.

So, we went to the Management Services package we installed earlier on the Sitecore instance and reinstalled it.  Sitecore CLI started working, so we must have something we are using in our solution that Management Services depends on.

Opening up the Sitecore package, we can see we had these assemblies:

Searching through every reference in every project, we found that our project that extended GraphQL depended on Sitecore.Services.GraphQL.  These versions were at 6.1.0.

<?xml version="1.0" encoding="utf-8"?>
<packages>  
  <package id="Sitecore.Services.GraphQL" version="6.1.0" targetFramework="net48" />
  <package id="Sitecore.Services.GraphQL.NetFxHost" version="6.1.0" targetFramework="net48" />
</packages>

So, we upgraded them to the versions Management Services was using.  After finding all the references and upgrading the versions to 6.1.1, Sitecore CLI started working.


The blog post is part of a series of blog posts on how to upgrade Sitecore CLI with Docker and manage the tooling with deployment tooling.  Going back to our process diagram:

This series will touch on these areas and how upgrading Sitecore CLI requires more to think about.

The next post will be on Docker - https://www.ehrendames.com/upgrading-sitecore-cli-and-docker/

Additional Reading: