NuGet CLI リファレンスNuGet CLI reference
NuGet コマンドラインインターフェイス (CLI) は、 nuget.exe
プロジェクトファイルを変更することなく、パッケージをインストール、作成、発行、および管理するためのすべての nuget 機能を提供します。The NuGet Command Line Interface (CLI), nuget.exe
, provides the full extent of NuGet functionality to install, create, publish, and manage packages without making any changes to project files.
任意のコマンドを使用するには、コマンドウィンドウまたは bash シェルを開き、を実行し nuget
た後、コマンドと、 nuget help pack
(パックコマンドのヘルプを表示する) などの適切なオプションを実行します。To use any command, open a command window or bash shell, then run nuget
followed by the command and appropriate options, such as nuget help pack
(to view help on the pack command).
このドキュメントには、最新バージョンの NuGet CLI が反映されています。This documentation reflects the latest version of the NuGet CLI. 使用している特定のバージョンの詳細については、目的のコマンドを実行して nuget help
ください。For exact details for any given version that you're using, run nuget help
for the desired command.
nuget.exe
CLI で基本的なコマンドを使用する方法を学習するには、nuget.exe CLI を使用したパッケージのインストールと使用に関するページを参照してください。To learn how to use basic commands with the nuget.exe
CLI, see Install and use packages using the nuget.exe CLI.
nuget.exe のインストールInstalling nuget.exe
WindowsWindows
注意
NuGet.exe 5.0 以降には、実行するために .NET Framework 4.7.2 以降が必要です。NuGet.exe 5.0 and later require .NET Framework 4.7.2 or later to execute.
- nuget.org/downloads にアクセスして、NuGet 3.3 以降を選択します (2.8.6 は Mono と互換性がありません)。Visit nuget.org/downloads and select NuGet 3.3 or higher (2.8.6 is not compatible with Mono). 常に最新バージョンが推奨され、パッケージを nuget.org に公開するには 4.1.0 以降が必要です。The latest version is always recommended, and 4.1.0+ is required to publish packages to nuget.org.
- 各ダウンロードは、直接
nuget.exe
ファイルです。Each download is thenuget.exe
file directly. ブラウザーで任意のフォルダーにファイルを保存します。Instruct your browser to save the file to a folder of your choice. ファイルがインストーラーでない場合、ブラウザーから直接実行しても何も表示されません。The file is not an installer; you won't see anything if you run it directly from the browser. nuget.exe
をPATH 環境変数に配置したフォルダーを追加し、任意の場所の CLI ツールを使用します。Add the folder where you placednuget.exe
to your PATH environment variable to use the CLI tool from anywhere.
macOS/LinuxmacOS/Linux
動作は、OS のディストリビューションによって微妙に異なる場合があります。Behaviors may vary slightly by OS distribution.
Mono 4.4.2 以降をインストールします。Install Mono 4.4.2 or later.
シェル プロンプトで次のコマンドを実行します。Execute the following command at a shell prompt:
# Download the latest stable `nuget.exe` to `/usr/local/bin` sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
次のスクリプトを OS の適切なファイルに追加してエイリアスを作成します (通常、
~/.bash_aliases
または~/.bash_profile
)。Create an alias by adding the following script to the appropriate file for your OS (typically~/.bash_aliases
or~/.bash_profile
):# Create as alias for nuget alias nuget="mono /usr/local/bin/nuget.exe"
シェルを再度読み込みます。Reload the shell. パラメーターなしで
nuget
を入力してインストールをテストします。Test the installation by enteringnuget
with no parameters. NuGet CLI ヘルプが表示されます。NuGet CLI help should display.
ヒント
Visual Studio のパッケージマネージャーコンソール内で NuGet CLI を使用できるようにする方法については、「 コンソールでの nuget.exe CLI の使用」を参照してください。To make the NuGet CLI available within the Package Manager Console in Visual Studio, see Using the nuget.exe CLI in the console.
可用性Availability
詳細については、「 機能の可用性 」を参照してください。See feature availability for exact details.
- Windows では、すべてのコマンドを使用できます。All commands are available on Windows.
- 、、およびに対して指定されている場合を除き、すべてのコマンドが Mono で実行される nuget.exe で動作
pack
restore
update
します。All commands work with nuget.exe running on Mono except where indicated forpack
,restore
, andupdate
. - 、、、
pack
restore
、およびの各delete
locals
push
コマンドは、dotnet CLI を使用して Mac および Linux でも使用できます。Thepack
,restore
,delete
,locals
, andpush
commands are also available on Mac and Linux through the dotnet CLI.
コマンドと適用性Commands and applicability
パッケージの作成、パッケージの使用、ホストへのパッケージの発行など、利用可能なコマンドと適用性。Available commands and applicability to package creation, package consumption, and/or publishing a package to a host:
一般的なコマンドCommon Commands | 適用可能な役割Applicable Roles | NuGet のバージョンNuGet Version | 説明Description |
---|---|---|---|
packpack | 作成Creation | 2.7 以降2.7+ | またはプロジェクトファイルから NuGet パッケージを作成し .nuspec ます。Creates a NuGet package from a .nuspec or project file. Mono で実行する場合、プロジェクトファイルからパッケージを作成することはサポートされていません。When running on Mono, creating a package from a project file is not supported. |
pushpush | 発行Publishing | すべてAll | パッケージをパッケージソースに発行します。Publishes a package to a package source. |
configconfig | AllAll | AllAll | NuGet 構成値を取得または設定します。Gets or sets NuGet configuration values. |
help or ?help or ? | AllAll | AllAll | コマンドのヘルプ情報またはヘルプを表示します。Displays help information or help for a command. |
localslocals | 従量課金Consumption | 3.3 +3.3+ | グローバルパッケージ、 http キャッシュ、および一時フォルダーの場所を一覧表示し、それらのフォルダーの内容をクリアします。Lists locations of the global-packages, http-cache, and temp folders and clears the contents of those folders. |
restorerestore | 従量課金Consumption | 2.7 以降2.7+ | 使用中のパッケージ管理形式で参照されているすべてのパッケージを復元します。Restores all packages referenced by the package management format in use. Mono で実行する場合、PackageReference 形式を使用したパッケージの復元はサポートされていません。When running on Mono, restoring packages using the PackageReference format is not supported. |
setapikeysetapikey | 発行、消費Publishing, Consumption | すべてAll | パッケージソースがアクセスのためにキーを必要とする場合に、指定されたパッケージソースの API キーを保存します。Saves an API key for a given package source when that package source requires a key for access. |
specspec | 作成Creation | すべてAll | .nuspec Visual Studio プロジェクトからファイルを生成する場合、トークンを使用してファイルを生成します。Generates a .nuspec file, using tokens if generating the file from a Visual Studio project. |
セカンダリコマンドSecondary Commands | 適用可能な役割Applicable Roles | NuGet のバージョンNuGet Version | 説明Description |
---|---|---|---|
addadd | 発行Publishing | 3.3 +3.3+ | 階層レイアウトを使用して、非 HTTP パッケージソースにパッケージを追加します。Adds a package to a non-HTTP package source using hierarchical layout. HTTP ソースの場合は、 pushを使用します。For HTTP sources, use push. |
deletedelete | 発行Publishing | すべてAll | パッケージソースからパッケージを削除または一覧から削除します。Removes or unlists a package from a package source. |
initinit | 作成Creation | 3.3 +3.3+ | 階層レイアウトを使用して、フォルダーからパッケージソースにパッケージを追加します。Adds packages from a folder to a package source using hierarchical layout. |
installinstall | 従量課金Consumption | すべてAll | 現在のプロジェクトにパッケージをインストールしますが、プロジェクトや参照ファイルは変更しません。Installs a package into the current project but does not modify projects or reference files. |
listlist | 消費 (おそらく発行)Consumption, perhaps Publishing | すべてAll | 指定されたソースからのパッケージを表示します。Displays packages from a given source. |
mirrormirror | 発行Publishing | 3.2 + で非推奨Deprecated in 3.2+ | パッケージとその依存関係をソースからターゲットリポジトリにミラー化します。Mirrors a package and its dependencies from a source to a target repository. |
searchsearch | 従量課金Consumption | 5.8 +5.8+ | 指定されたクエリ文字列を使用して、指定されたソースを検索します。Searches a given source using the query string provided. |
sourcessources | 消費、発行Consumption, Publishing | すべてAll | 構成ファイルのパッケージソースを管理します。Manages package sources in configuration files. |
updateupdate | 従量課金Consumption | すべてAll | プロジェクトのパッケージを、使用可能な最新バージョンに更新します。Updates a project's packages to the latest available versions. Mono で実行する場合はサポートされません。Not supported when running on Mono. |
さまざまなコマンドによって、さまざまな 環境変数が使用できます。Different commands make use of various Environment variables.
適用可能なロール別の NuGet CLI コマンド:NuGet CLI commands by applicable roles:
RoleRole | コマンドCommands |
---|---|
従量課金Consumption | config , help , install , list , locals , restore , search , setapikey , sources , update config , help , install , list , locals , restore , search , setapikey , sources , update |
作成Creation | config , help , init , pack , spec config , help , init , pack , spec |
発行Publishing | add , config , delete , help , list , push , setapikey , sources add , config , delete , help , list , push , setapikey , sources |
たとえば、パッケージの使用のみを懸念している開発者は、NuGet コマンドのサブセットのみを理解する必要があります。Developers concerned only with consuming packages, for example, need only understand that subset of NuGet commands.
注意
コマンドオプション名では大文字と小文字が区別されません。Command option names are case-insensitive. 非推奨のオプションは、この参照には含まれません NoPrompt
(で置き換えられる NonInteractive
) と Verbose
(によって置き換えられ Verbosity
ます)。Options that are deprecated are not included in this reference, such as NoPrompt
(replaced by NonInteractive
) and Verbose
(replaced by Verbosity
).