Skip to content

Commit 4e8c6d3

Browse files
Update documentation for dotnet package list command (#49053)
1 parent aec2cd6 commit 4e8c6d3

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

docs/core/tools/dotnet-package-list.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dotnet package list [--config <SOURCE>]
2121
[--deprecated] [--project [<PROJECT>|<SOLUTION>]]
2222
[-f|--framework <FRAMEWORK>] [--highest-minor] [--highest-patch]
2323
[--include-prerelease] [--include-transitive] [--interactive]
24-
[--outdated] [--source <SOURCE>] [-v|--verbosity <LEVEL>]
24+
[--no-restore] [--outdated] [--source <SOURCE>] [-v|--verbosity <LEVEL>]
2525
[--vulnerable]
2626
[--format <console|json>]
2727
[--output-version <VERSION>]
@@ -31,9 +31,15 @@ dotnet package list -h|--help
3131

3232
## Description
3333

34-
The `dotnet package list` command provides a convenient option to list all NuGet package references for a specific project or a solution. You first need to build the project in order to have the assets needed for this command to process. The following example shows the output of the `dotnet package list` command for the [SentimentAnalysis](https://github.com/dotnet/samples/tree/main/machine-learning/tutorials/SentimentAnalysis) project:
34+
The `dotnet package list` command provides a convenient option to list all NuGet package references for a specific project or a solution.
35+
Starting with **.NET 10**, the command automatically performs restore if necessary before generating the results.
36+
In earlier versions, you first need to **build/restore the project** in order to have the assets needed for this command to process.
37+
The following example shows the output of the `dotnet package list` command for the [SentimentAnalysis](https://github.com/dotnet/samples/tree/main/machine-learning/tutorials/SentimentAnalysis) project:
3538

3639
```output
40+
Restore complete (5.9s)
41+
42+
Build succeeded in 6.0s
3743
Project 'SentimentAnalysis' has the following package references
3844
[netcoreapp2.1]:
3945
Top-level Package Requested Resolved
@@ -45,11 +51,28 @@ Project 'SentimentAnalysis' has the following package references
4551

4652
The **Requested** column refers to the package version specified in the project file and can be a range. The **Resolved** column lists the version that the project is currently using and is always a single value. The packages displaying an `(A)` right next to their names represent implicit package references that are inferred from your project settings (`Sdk` type, or `<TargetFramework>` or `<TargetFrameworks>` property).
4753

54+
If you want to skip the automatic restore, you can use the `--no-restore` option.
55+
Example `dotnet package list --no-restore`:
56+
57+
```output
58+
Project 'SentimentAnalysis' has the following package references
59+
[netcoreapp2.1]:
60+
Top-level Package Requested Resolved
61+
> Microsoft.ML 1.4.0 1.4.0
62+
> Microsoft.NETCore.App (A) [2.1.0, ) 2.1.0
63+
64+
(A) : Auto-referenced package.
65+
```
66+
4867
Use the `--outdated` option to find out if there are newer versions available of the packages you're using in your projects. By default, `--outdated` lists the latest stable packages unless the resolved version is also a prerelease version. To include prerelease versions when listing newer versions, also specify the `--include-prerelease` option. To update a package to the latest version, use [dotnet package add](dotnet-package-add.md).
4968

5069
The following example shows the output of the `dotnet package list --outdated --include-prerelease` command for the same project as the previous example:
5170

5271
```output
72+
Restore complete (0.6s)
73+
74+
Build succeeded in 0.7s
75+
5376
The following sources were used:
5477
https://api.nuget.org/v3/index.json
5578
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
@@ -63,6 +86,9 @@ Project `SentimentAnalysis` has the following updates to its packages
6386
If you need to find out whether your project has transitive dependencies, use the `--include-transitive` option. Transitive dependencies occur when you add a package to your project that in turn relies on another package. The following example shows the output from running the `dotnet package list --include-transitive` command for the [HelloPlugin](https://github.com/dotnet/samples/tree/main/core/extensions/AppWithPlugin/HelloPlugin) project, which displays top-level packages and the packages they depend on:
6487

6588
```output
89+
Restore complete (0.6s)
90+
91+
Build succeeded in 0.7s
6692
Project 'HelloPlugin' has the following package references
6793
[netcoreapp3.0]:
6894
Transitive Package Resolved
@@ -109,6 +135,10 @@ The project or solution file to operate on. If not specified, the command search
109135

110136
[!INCLUDE [interactive](../../../includes/cli-interactive-3-0.md)]
111137

138+
- **`--no-restore`**
139+
140+
Don't restore before running the command.
141+
112142
- **`--outdated`**
113143

114144
Lists packages that have newer versions available.

0 commit comments

Comments
 (0)