Tailwind Logo

Sitecore CLI installation for macOS

CLI

Published: 2022-05-23

Sitecore CLI, Sitecore's command line tool, will be installed on macOS this time. This is because Sitecore CLI also runs on macOS since it is provided as a command that runs on PowerShell Core and .NET Core 3.1 base.

Installation in a Windows environment has already been introduced in the following page.

Install

PowerShell must be installed in order to use the Sitecore CLI. If you have already installed PowerShell, you can skip this step. This time, since we will install using Homebrew, please check the official website for Homebrew and install it.

Installing PowerShell for macOS

PowerShell installation is automatically set up with a single command line if homebrew is already installed. Open a terminal and execute the following command

Bash
brew install powershell --cask
sitecorecli01.png

After installation is complete, verify that it starts with the following command

Bash
pwsh
sitecorecli02.png

Installing .NET Core 3.1

Next, install .NET Core 3.1. Download the installer from the following site and install it.

sitecorecli03.png

After installation, dotnet commands may not work because the path is not followed. To get it to work, add a symbolic link. Note that on my macOS, I installed the x64 binary, so I ran the following commands.

Bash
sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin
sitecorecli04.png

Install Sitecore CLI

From here, we will make it available on a per-project basis, just as we did with the previous installation. First, move the directory (if it does not exist, create it).

PowerShell
cd Projects/SampleDemo

First, create a definition file.

PowerShell
dotnet new tool-manifest

The next step is to set up the nuget gallery, which can be omitted if it has already been done previously.

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

Finally, install the command

PowerShell
dotnet tool install Sitecore.CLI
sitecorecli05.png

The command is now installed. Initialize and install the plug-ins.

PowerShell
dotnet sitecore init
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Publishing
sitecorecli06.png

Login

Login to the actual Sitecore instance. Specify the edit server and authentication server. The following is a sample domain name.

PowerShell
dotnet sitecore login --cm https://shinharaxm-cm.sitecoredemo.com/ --auth https://shinharaxm-id.sitecoredemo.com/ --allow-write true
sitecorecli07.png

After executing the command, the browser will start and the login screen will appear.

sitecorecli08.png

After performing the login, the screen will switch to a confirmation screen asking if you wish to grant privileges.

sitecorecli09.png

If you allow it, the command line screen switches from the login confirmation mode, indicating that the login is complete.

sitecorecli10.png

We have confirmed that you can log in.

Operation check

We will actually execute the command and check the result. This time, since we have not prepared data to be imported, we will update the Index as follows.

PowerShell
dotnet sitecore index schema-populate
dotnet sitecore index rebuild
sitecorecli11.png

We were able to successfully execute the process on the command line for the remotely prepared Sitecore instance.

Summary

We have confirmed that Sitecore CLI is also available for macOS. If headless development is the main focus, it will be possible to develop on macOS and work with servers deployed in the cloud. NET Core is now available for macOS, and the tools are supported, so we can work on non-Windows platforms as well.

Tags