---
title: "Sitecoreコマンドラインインターフェースをインストールする"
slug: "install-sitecore-command-line-interface"
abstract: "ターミナルにSitecoreコマンドラインインターフェース(CLI)をインストールする方法。"
---
# Sitecoreコマンドラインインターフェースをインストールする

[Sitecoreコマンドラインインターフェース(CLI)](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/sitecore-command-line-interface.html "Sitecore Command Line Interface") は、ターミナルにインストールするツールです。

> !注既存のCLIインストールをアップグレードするには、「 [Sitecoreコマンドラインインターフェースのアップグレード](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/upgrade-the-sitecore-command-line-interface-to-version-5.html "Upgrade the Sitecore Command Line Interface to version 5")」をご覧ください。

Sitecore CLIは個別プロジェクト用のローカルツールとしてインストールすることも、すべてのプロジェクト用のグローバルツールとしてインストールできます。

> !重要Sitecore CLIをグローバルツールとしてインストールすることは推奨しません。異なるSitecoreインスタンスによって異なるバージョンのSitecore CLIが必要になる場合があります。

Sitecore CLIをインストールする前に、ワークステーションに [.NET 10](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)をインストールしている必要があります。必要な.NET Coreのバージョンをインストールしていない場合、以下のメッセージが表示されます。

Package sitecore.cli {version} is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any. 
Package sitecore.cli {version} supports: net10.0 (.NETCoreApp,Version=v10.0) / any

Sitecore CLIをローカルプロジェクトツールとしてインストールするには:

1.  まだであれば、[Sitecore Management Servicesをインストールし](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/sitecore-management-services.html "Sitecore Management Services")てください。
    
    > !重要バージョン5.1.25以降、CLIには [バージョン互換性機能](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/version-compatibility.html "Version compatibility") があり、古いSitecore Management ServicesのバージョンでCLIコマンドを実行できないようにします。
    
2.  管理者権限で端末を開いてください。
    
3.  Sitecore CLIをインストールするには以下のコマンドを実行してください:
    
    cd <project folder>
    dotnet new tool-manifest
    dotnet nuget add source -n Sitecore https://nuget.sitecore.com/resources/v3/index.json
    dotnet tool install Sitecore.CLI
    
    > !注同じプロジェクトに取り組む他の開発者はSitecore CLIをインストールするためにdotnet tool restoreのみを実行させる必要があります。
    > 
    > CLIを全体にインストールするには、installコマンドを実行するときに\-gオプションを使用してください(推奨されません)。
    
    インストールが完了すると、以下のメッセージが表示されます:
    
    You can invoke the tool from this directory using the following commands: 'dotnet tool run sitecore' or 'dotnet sitecore'.
    Tool 'sitecore.cli' {version} was successfully installed. Entry is added to the manifest file {project-path}.config\\dotnet-tools.json.
    
4.  新しいプロジェクトを初期化するには、プロジェクトフォルダ内の以下のコマンドを実行してください:
    
    dotnet sitecore init
    
    > !注コマンドdotnet sitecore initは、CLIと同じバージョンのデフォルトプラグインをsitecore.jsonファイルに追加します。プラグインはSitecore.DevEx.Extensibility.Serialization、Sitecore.DevEx.Extensibility.Publishing、Sitecore.DevEx.Extensibility.Indexing、Sitecore.DevEx.Extensibility.ResourcePackage、Sitecore.DevEx.Extensibility.Databaseです。次のSitecore CLIコマンドでは、CLIがプラグインの解析とインストールを試みます。
    
5.  プロジェクトの初期化を以下のコマンドで確認してください:
    
    dotnet sitecore plugin list
    
    もしこれがdotnet sitecore initの後の最初のコマンドであれば、CLIはsitecore.jsonファイルに記載されたプラグインを解決しインストールしようとします。コマンドはインストールされているプラグインを知らせるメッセージを印刷します。例えば:
    
    \>> Begin installing NuGet packages: Sitecore.DevEx.Extensibility.Serialization@{version}, Sitecore.DevEx.Extensibility.Publishing@{version}, Sitecore.DevEx.Extensibility.Indexing@{version}, Sitecore.DevEx.Extensibility.ResourcePackage@{version}, Sitecore.DevEx.Extensibility.Database@{version}
    
    インストールが成功した場合、コマンドはインストール済みプラグインとそのバージョン情報を一覧表示します:
    
    List of plugins:
    Installed Sitecore.DevEx.Extensibility.Serialization v.{version}
    Installed Sitecore.DevEx.Extensibility.Publishing v.{version}
    Installed Sitecore.DevEx.Extensibility.Indexing v.{version}
    Installed Sitecore.DevEx.Extensibility.ResourcePackage v.{version}
    Installed Sitecore.DevEx.Extensibility.Database v.{version}
    
    プラグインのインストールが失敗した場合、出力はそのプラグインのFailed状態を表示します。
    
6.  Sitecore CLIが動作するか確認するには、ターミナルのプロジェクトフォルダに行き、dotnet sitecore -hと入力してください。
    
    Sitecore CLIが準備できれば、使用状況、オプション、[利用可能なトップレベルコマンド](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/sitecore-command-line-interface-reference.html "Sitecore Command Line Interface reference")を説明するメッセージが表示されます。例えば:
    
    sitecore.cli
     Sitecore command line tool
    
    Usage:
     sitecore.cli options command
    
    Options:
     --version Show version information
     -?, -h, --help Show help and usage information
    
    Commands:
     login Authenticates the CLI to a Sitecore instance
     plugin Manage plugins commands
     init Creates Sitecore configurations in current directory
     connect Connect to the existing environment
     ser, serialization Item serialization commands
     publish Performs a publish operation on all content
     index working with indexes data
     itemres Resource Items Package commands
     dbcleanup Performs cleanup operations for Sitecore databases