Sitecore Command Line Interfaceのインストール
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
Sitecore Command Line Interface (CLI) は、ターミナルにインストールするツールです。
既存のCLIインストールをアップグレードするには、「 Sitecoreコマンド ライン インターフェイスのアップグレード」を参照してください。
Sitecore CLIは、個々のプロジェクトのローカル ツールとして、またはすべてのプロジェクトのグローバル ツールとしてインストールできます。
Sitecore CLIをグローバル ツールとしてインストールすることはお勧めしません。Sitecoreインスタンスが異なれば、Sitecore CLIのバージョンも異なる場合があります。
Sitecore CLIをインストールする前に、ワークステーションに .NET 8がインストールされている必要があります。必要なバージョンの .NET Coreがインストールされていない場合は、次のメッセージが表示されます。
Package sitecore.cli {version} is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any.
Package sitecore.cli {version} supports: net8.0 (.NETCoreApp,Version=v8.0) / any
Sitecore CLIをローカル プロジェクト ツールとしてインストールするには:
-
Sitecore Management Servicesをまだインストールしていない場合は、インストールします。
大事なバージョン5.1.25以降、CLIには バージョン互換性機能 があり、古いバージョンのSitecore Management ServicesでCLIコマンドを実行できなくなります。
-
管理者権限でターミナルを開きます。
-
次のコマンドを実行して、Sitecore CLIをインストールします。
RequestResponsecd <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オプションを使用します (推奨されません)。
インストールが完了すると、次のメッセージが表示されます。
RequestResponseYou 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.
-
新しいプロジェクトを初期化するには、プロジェクト フォルダーで次のコマンドを実行します。
RequestResponsedotnet 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はプラグインの解決とインストールを試みます。
-
次のコマンドを使用して、プロジェクトの初期化を確認します。
RequestResponsedotnet sitecore plugin list
これがdotnet sitecore initの後の最初のコマンドである場合、CLIはsitecore.jsonファイルにリストされているプラグインの解決とインストールを試みます。このコマンドは、インストールされているプラグインを通知するメッセージを出力します。例えば:
RequestResponse>> 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}
インストールが成功すると、コマンドはインストールされているプラグインとそのバージョン情報を一覧表示します。
RequestResponseList 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ステータスが表示されます。
-
Sitecore CLIが機能することを確認するには、ターミナルでプロジェクト フォルダーに移動し、「 dotnet sitecore -h」と入力します。
Sitecore CLIの準備ができている場合は、使用方法、オプション、および使用可能な最上位コマンドを説明するメッセージが表示されます。例えば:
RequestResponsesitecore.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