Skip to content

Commit e2eeef4

Browse files
authored
Freshness Edit: NuGet (#3558)
* Refresh article * Adjust wording * Address Copilot comment: change description of restore command
1 parent 30be3b3 commit e2eeef4

2 files changed

Lines changed: 57 additions & 39 deletions

File tree

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
The [dotnet restore](/dotnet/core/tools/dotnet-restore) command restores packages that the project file lists with `<PackageReference>`. For more information, see [PackageReference in project files](../../consume-packages/package-references-in-project-files.md).
1+
The [`dotnet restore`](/dotnet/core/tools/dotnet-restore) command restores packages that are listed in `<PackageReference>` elements in the project file. For more information, see [`PackageReference` in project files](../../consume-packages/Package-References-in-Project-Files.md).
22

3-
.NET Core 2.0 and later `dotnet build` and `dotnet run` commands restore packages automatically. As of NuGet 4.0, `dotnet restore` runs the same code as `nuget restore`.
3+
Starting with .NET Core 2.0 and continuing through .NET, the `dotnet build` and `dotnet run` commands restore packages automatically, as do many other dotnet CLI commands. As of NuGet 4.0, `dotnet restore` runs the same code as the `nuget restore` NuGet CLI command.
44

5-
To restore a package with `dotnet restore`:
5+
To restore packages by using `dotnet restore`:
66

7-
1. Open a command line and switch to the directory that contains your project file.
7+
1. Open a command-line window and go to the directory that contains your project file.
88
1. Run `dotnet restore`.
9-
Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,115 @@
11
---
2-
title: Install and manage NuGet packages with the dotnet CLI
3-
description: See how to use the dotnet CLI to install, list, remove, and update NuGet packages.
2+
title: Install and Manage NuGet Packages with the dotnet CLI
3+
description: Find out how to use the dotnet command-line interface (CLI) to install, list, remove, and update NuGet packages in .NET projects.
44
author: mikejo5000
55
ms.author: mikejo
6-
ms.date: 03/03/2025
7-
ms.topic: install-set-up-deploy
6+
ms.date: 04/17/2026
7+
ms.topic: how-to
8+
# customer intent: As a developer, I want to find out how to use the dotnet CLI to manage NuGet packages so that I can use the packages in .NET projects.
89
---
910

1011
# Install and manage NuGet packages with the dotnet CLI
1112

12-
You can use the dotnet CLI tool on Windows, macOS, or Linux to easily install, uninstall, and update NuGet packages in .NET projects and solutions. This article describes the most common dotnet CLI commands for managing NuGet packages.
13+
You can use the dotnet command-line interface (CLI) tool on Windows, macOS, or Linux to easily install, uninstall, and update NuGet packages in .NET projects and solutions. This article describes the most common dotnet CLI commands for managing NuGet packages.
1314

14-
The dotnet CLI runs on .NET, .NET Core, .NET Standard SDK-style projects, and any other SDK-style projects, for example those that target .NET Framework. For more information, see [.NET project SDKs](/dotnet/core/project-sdk/overview).
15+
The dotnet CLI runs on .NET, .NET Core, .NET Standard SDK-style projects, and any other SDK-style projects, for example, those that target .NET Framework. For more information, see [.NET project SDKs](/dotnet/core/project-sdk/overview).
1516

16-
For most commands, the CLI tool looks for a project file in the current directory, unless a different project file is specified as an optional switch in the command. For a complete list of commands and their arguments, see [dotnet CLI commands](../reference/dotnet-commands.md).
17+
For most commands, the CLI tool looks for a project file in the current directory, unless a different project file is specified as an optional switch in the command. For a complete list of commands and their arguments, see [dotnet CLI commands](../reference/dotnet-Commands.md).
1718

1819
## Prerequisites
1920

20-
- The [.NET Core SDK](https://www.microsoft.com/net/download/), which provides the `dotnet` command-line tool. Starting in Visual Studio 2017, the dotnet CLI automatically installs with all .NET and .NET Core related workloads.
21+
The [.NET SDK](https://dotnet.microsoft.com/download), which provides the dotnet CLI. In Visual Studio, the dotnet CLI automatically installs with all .NET-related workloads.
2122

2223
## Install or update a package
2324

24-
The [dotnet add package](/dotnet/core/tools/dotnet-add-package) command adds a package reference to the project file, and then runs `dotnet restore` to install the package.
25+
The [dotnet package add](/dotnet/core/tools/dotnet-package-add) command adds a package reference to the project file, and then runs `dotnet restore` to install the package.
2526

26-
1. Open a command line and switch to the directory that contains your project file.
27+
1. Open a command-line window and go to the directory that contains your project file.
2728

2829
1. Use the following command to install a NuGet package:
2930

30-
```dotnetcli
31-
dotnet add package <PACKAGE_NAME>
32-
```
31+
```dotnetcli
32+
dotnet package add <package-name>
33+
```
3334

34-
For example, to install the `Newtonsoft.Json` package, use the following command
35+
For example, to install the `Newtonsoft.Json` package, use the following command:
3536

36-
```dotnetcli
37-
dotnet add package Newtonsoft.Json
38-
```
37+
```dotnetcli
38+
dotnet package add Newtonsoft.Json
39+
```
3940

40-
1. After the command completes, you can open the project file to see the package reference.
41+
If you're using .NET 9 or earlier, use the verb-first form of the command instead:
4142

42-
For example, open the *.csproj* file to see the added `Newtonsoft.Json` package reference:
43+
```dotnetcli
44+
dotnet add package <package-name>
45+
```
4346

44-
```xml
45-
<ItemGroup>
46-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
47-
</ItemGroup>
48-
```
47+
1. After the command finishes, open the project file to check for the package reference.
48+
49+
For example, open the *.csproj* file and check for the added `Newtonsoft.Json` package reference:
50+
51+
```xml
52+
<ItemGroup>
53+
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
54+
</ItemGroup>
55+
```
4956

5057
## Install a specific version of a package
5158

52-
The `dotnet add package` command installs the latest version of the package unless you specify a different version.
59+
The `dotnet package add` command installs the latest version of the package unless you specify a different version.
5360

5461
To install a specific version of a NuGet package, use the optional `-v` or `--version` switch:
5562

5663
```dotnetcli
57-
dotnet add package <PACKAGE_NAME> -v <VERSION>
64+
dotnet package add <package-name> -v <version>
5865
```
5966

60-
For example, to add version 12.0.1 of the `Newtonsoft.Json` package, use this command:
67+
For example, to add version 13.0.1 of the `Newtonsoft.Json` package, use this command:
6168

6269
```dotnetcli
63-
dotnet add package Newtonsoft.Json --version 12.0.1
70+
dotnet package add Newtonsoft.Json --version 13.0.1
6471
```
6572

6673
## List package references
6774

68-
List the package references and versions for your project by using the [dotnet list package](/dotnet/core/tools/dotnet-list-package) command:
75+
You can use the [dotnet package list](/dotnet/core/tools/dotnet-package-list) command to list the package references and versions for your project. From the directory that contains your project file, run the following command:
76+
77+
```dotnetcli
78+
dotnet package list
79+
```
80+
81+
If you're using .NET 9 or earlier, use the verb-first form instead:
6982

7083
```dotnetcli
7184
dotnet list package
7285
```
7386

7487
## Remove a package
7588

76-
Use the [dotnet remove package](/dotnet/core/tools/dotnet-remove-package) command to remove a package reference from the project file.
89+
You can use the [dotnet package remove](/dotnet/core/tools/dotnet-package-remove) command to remove a package reference from the project file. From the directory that contains your project file, run the following command:
7790

7891
```dotnetcli
79-
dotnet remove package <PACKAGE_NAME>
92+
dotnet package remove <package-name>
8093
```
8194

8295
For example, to remove the `Newtonsoft.Json` package, use the following command:
8396

8497
```dotnetcli
85-
dotnet remove package Newtonsoft.Json
98+
dotnet package remove Newtonsoft.Json
99+
```
100+
101+
If you're using .NET 9 or earlier, use the verb-first form instead:
102+
103+
```dotnetcli
104+
dotnet remove package <package-name>
86105
```
87106

88107
## Restore packages
89108

90109
[!INCLUDE [restore-dotnet-cli](includes/restore-dotnet-cli.md)]
91110

92-
## Next steps
111+
## Related content
93112

94113
- [.NET CLI overview](/dotnet/core/tools)
95114
- [Install and manage packages in Visual Studio using the NuGet Package Manager](install-use-packages-visual-studio.md)
96-
- [Install and manage packages with the Package Manager Console](install-use-packages-powershell.md)
115+
- [Manage packages with the Visual Studio Package Manager Console (PowerShell)](install-use-packages-powershell.md)

0 commit comments

Comments
 (0)