Skip to content

Commit ea63a75

Browse files
committed
Refresh article
1 parent 76b484c commit ea63a75

2 files changed

Lines changed: 25 additions & 24 deletions

File tree

docs/consume-packages/includes/restore-nuget-exe-cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The NuGet CLI [restore](../../reference/cli-reference/cli-ref-restore.md) command downloads and installs any missing packages. The command works on projects that use either [PackageReference](/nuget/consume-packages/package-references-in-project-files) or [packages.config](/nuget/reference/packages-config) for package references.
1+
The NuGet CLI [`restore`](../../reference/cli-reference/cli-ref-restore.md) command downloads and installs any missing packages. The command works on projects that use either [`PackageReference`](../package-references-in-project-files) or [packages.config](../../reference/packages-config) for package references.
22

33
Like `install`, the `restore` command only adds packages to disk. It doesn't modify the project file or *packages.config* file. To add project dependencies, use the Visual Studio Package Manager UI or console.
44

@@ -17,4 +17,4 @@ nuget restore MySolution.slnx
1717
```
1818

1919
> [!NOTE]
20-
> For non-SDK-style projects that use `PackageReference`, use [msbuild -t:restore](../package-restore.md#restore-using-msbuild) to restore packages instead.
20+
> For non-SDK-style projects that use `PackageReference`, the recommended approach is to use [`msbuild -t:restore`](../package-restore.md#restore-using-msbuild) to restore packages instead of the `nuget restore` command. The `msbuild -t:restore` command uses the same project evaluation and resolution logic as the build, which helps to ensure consistent and reliable dependency resolution.
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
11
---
22
title: Manage NuGet Packages with the NuGet CLI
3-
description: Instructions for using the NuGet CLI, nuget.exe, to manage NuGet packages.
3+
description: Find out how to use the NuGet CLI, nuget.exe, to manage NuGet packages in non-SDK-style projects that use a packages.config file to list package references.
44
author: mikejo5000
55
ms.author: mikejo
6-
ms.date: 03/03/2025
6+
ms.date: 04/08/2026
77
ms.topic: how-to
8+
# customer intent: As a developer, I want to find out how to use the NuGet CLI so that I can manage NuGet packages in my projects and solutions.
89
---
910

1011
# Manage NuGet packages with the NuGet CLI
1112

12-
You can use the `nuget.exe` command-line interface (CLI) to manage NuGet packages in Visual Studio projects and solutions. This article describes the most common NuGet CLI commands for managing NuGet packages. All these commands work on Windows, and most work on Mac and on Linux with Mono.
13+
You can use the `nuget.exe` command-line interface (CLI) to manage NuGet packages in Visual Studio projects and solutions. This article describes the most common NuGet CLI commands for managing NuGet packages. All these commands work on Windows, and most work on macOS and on Linux with Mono.
1314

1415
The NuGet CLI runs on .NET Framework and non-SDK-style projects, for example non-SDK style projects that target .NET Standard libraries. The NuGet CLI commands can use a project [packages.config](../reference/packages-config.md) file that lists package references. For non-SDK-style projects that use `PackageReference` instead of *packages.config* for package references, use the [dotnet CLI](install-use-packages-dotnet-cli.md) instead.
1516

1617
> [!NOTE]
1718
> For most non-SDK-style projects that use *packages.config*, it's best to [migrate packages.config to `PackageReference`](migrate-packages-config-to-package-reference.md), and then use the dotnet CLI instead of the NuGet CLI to manage packages. However, you can't migrate C++ or ASP.NET projects.
1819
19-
For most commands, the NuGet CLI tool uses the current directory, unless you specify a different location in the command. To run NuGet CLI commands, open a command-line program and switch to the directory that contains your project file.
20+
For most commands, the NuGet CLI tool uses the current folder, unless you specify a different location in the command. To run NuGet CLI commands, open a command-line program and switch to the folder that contains your project file.
2021

2122
For a complete list of commands and their arguments, see [NuGet CLI reference](../reference/nuget-exe-cli-reference.md).
2223

2324
## Prerequisites
2425

25-
Download the NuGet CLI from [nuget.org](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe). Save the *nuget.exe* file to a suitable directory, and make sure the directory is in your `PATH` environment variable.
26+
Download the NuGet CLI from [nuget.org](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe). Save the *nuget.exe* file to a suitable folder, and make sure the folder is in your `PATH` environment variable.
2627

2728
> [!NOTE]
28-
> You can also use the [winget](/windows/package-manager/winget) tool for Windows or [Homebrew](https://brew.sh/) for macOS.
29+
> You can also use the [`winget`](/windows/package-manager/winget) tool for Windows or [Homebrew](https://brew.sh/) for macOS.
2930
30-
To find out your NuGet CLI version, open a command-line program and run `nuget help`. Or to avoid having to scroll up, use `nuget help | more`. The first line in the help output shows the version.
31+
To check your NuGet CLI version, open a command-line program and run `nuget help`. Or to avoid having to scroll up, use `nuget help | more`. The first line in the help output shows the version.
3132

3233
## Install a package
3334

34-
The NuGet CLI [install](../reference/cli-reference/cli-ref-install.md) command downloads and installs specified NuGet packages.
35+
The NuGet CLI [`install`](../reference/cli-reference/cli-ref-install.md) command downloads and installs specified NuGet packages.
3536

3637
> [!IMPORTANT]
37-
> The `install` command doesn't modify the project file or *packages.config* file. The `install` and `restore` commands only add packages to disk, but don't add dependencies to projects. To add project dependencies, add packages through the [Visual Studio Package Manager UI](install-use-packages-visual-studio.md) or [Package Manager Console](install-use-packages-powershell.md), then run `install` or `restore`.
38+
> The `install` command doesn't modify the project file or *packages.config* file. The `install` and `restore` commands only add packages to disk, but don't add dependencies to projects. To add project dependencies, add packages by using the [Visual Studio Package Manager UI](install-use-packages-visual-studio.md) or [Package Manager Console](install-use-packages-powershell.md). If you then run `install` or `restore`, perhaps in another environment, only the declared dependencies are installed or restored.
3839
39-
Use the `-OutputDirectory` option to install packages to a specific directory. If you don't specify an output directory, `install` uses the current directory.
40+
Use the `-OutputDirectory` option to install packages in a specific folder. If you don't specify an output folder, `install` uses the current folder.
4041

4142
```cli
42-
nuget install <package-ID | configuration-file-path> -OutputDirectory <output-directory>
43+
nuget install <package-ID | configuration-file-path> -OutputDirectory <output-folder>
4344
```
4445

45-
For example, to install the `Newtonsoft.json` package in the *packages* subdirectory, use the following command:
46+
For example, to install the `Newtonsoft.json` package in the *packages* subfolder, use the following command:
4647

4748
```cli
4849
nuget install Newtonsoft.Json -OutputDirectory packages
4950
```
5051

51-
Instead of specifying a package to install, you can specify an existing *packages.config* file in the current directory or another directory. The `install` command installs all the packages listed in the *packages.config* file.
52+
Instead of specifying a package to install, you can specify an existing *packages.config* file in the current folder or another folder. The `install` command installs all the packages listed in the *packages.config* file.
5253

5354
```cli
5455
nuget install packages.config
5556
```
5657

57-
For example, the following command installs all the packages listed in *packages.config* in the *config* subdirectory of the current directory. The command installs the packages in the *packages* directory.
58+
For example, the following command installs all the packages listed in *packages.config* in the *config* subfolder of the current folder. The command installs the packages in the *packages* folder.
5859

5960
```cli
6061
nuget install config\packages.config -OutputDirectory packages
@@ -66,7 +67,7 @@ nuget install config\packages.config -OutputDirectory packages
6667
The `install` command installs the latest version of a package unless you specify a different version. To install a specific version of a package, use the `-Version` option:
6768

6869
```cli
69-
nuget install <package-ID | configuration-file-path> -Version <version>
70+
nuget install <package-ID> -Version <version>
7071
```
7172

7273
For example, to install version 12.0.1 of the `Newtonsoft.json` package, use:
@@ -77,13 +78,13 @@ nuget install Newtonsoft.Json -Version 12.0.1
7778

7879
## List packages
7980

80-
Use the [search](../reference/cli-reference/cli-ref-search.md) command to display basic information about packages at a specified source.
81+
Use the [`search`](../reference/cli-reference/cli-ref-search.md) command to display basic information about packages at a specified source.
8182

8283
```cli
8384
nuget search -Source <source>
8485
```
8586

86-
For example, to list packages in the *packages* subdirectory of *MyProject*, use the following command:
87+
For example, to list packages in the *packages* subfolder of *MyProject*, use the following command:
8788

8889
```cli
8990
nuget search -Source C:\Users\%USERNAME%\source\repos\MyProject\packages
@@ -92,12 +93,12 @@ nuget search -Source C:\Users\%USERNAME%\source\repos\MyProject\packages
9293
You can also specify search terms to limit the results by package names, tags, or descriptions:
9394

9495
```cli
95-
nuget list <search-terms> -Source <source>
96+
nuget search <search-terms> -Source <source>
9697
```
9798

9899
## Update all packages
99100

100-
Use the [update](../reference/cli-reference/cli-ref-update.md) command to update all packages in a project *packages.config* file to their latest available versions. For `<configuration-file-path>`, use the path to your *packages.config* file.
101+
Use the [`update`](../reference/cli-reference/cli-ref-update.md) command to update all packages in a project *packages.config* file to their latest available versions. For `<configuration-file-path>`, use the path to your *packages.config* file.
101102

102103
```cli
103104
nuget update <configuration-file-path>
@@ -117,9 +118,9 @@ Deleting packages from disk doesn't update the project, *packages.config*, or *N
117118

118119
For more information, see [Restore packages](package-restore.md).
119120

120-
## Next steps
121+
## Related content
121122

122123
- [NuGet CLI reference](../reference/nuget-exe-cli-reference.md)
123124
- [Install and manage packages in Visual Studio using the NuGet Package Manager](install-use-packages-visual-studio.md)
124-
- [Migrate from packages.config to PackageReference](migrate-packages-config-to-package-reference.md)
125-
- [Manage packages with the dotnet CLI](install-use-packages-dotnet-cli.md)
125+
- [Migrate from packages.config to `PackageReference`](migrate-packages-config-to-package-reference.md)
126+
- [Install and manage NuGet packages with the dotnet CLI](install-use-packages-dotnet-cli.md)

0 commit comments

Comments
 (0)