-
Notifications
You must be signed in to change notification settings - Fork 265
dotnet list package
- Currently the VS PM UI shows a list of the installed packages and the updates available for them, a similar functionality with the CLI is needed.
- Unlisted/Vulnerable/Obsolete packages should be flagged both in the PM UI and using CLI commands. See issue: Deprecate obsolete, vulnerable or legacy packages #2867
We should have a list package command that can list the installed packages for the developers. For the first version, the list package command will work only with the dotnet command line with package reference projects. Support for nuget.exe and package config projects will come in later versions.
Running in the project folder - Shows all packages, by default
> dotnet list package <optional project path or solution path>
Project '.\project.csproj' has the following package references -
'netstandard1.0'
Top-level Package Requested Resolved
> NETStandard.Library (A) 2.0.3 2.0.3
> nuget.versioning [4.0.0, 4.3.0) 4.0.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta
'net45'
Transitive Package Requested Resolved
> NETStandard.Library (A) 2.0.3 2.0.3
> nuget.versioning [4.0.0, 4.3.0) 4.0.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta
A: Auto-referenced package
>
Behavior clarification:
- Requested column will include the version that the developer has indicated in the package reference tags within the project file, which means it can be a range. Resolved column will include the version that the project is currently using and will always be a single value.
- In the absence of an assets file, the command will show a message saying that an assets file was not found, and will suggest running
dotnet restorebefore running list.
The command will have the following options:
list package command option |
Behavior |
|---|---|
--outdated |
Displays the latest version for the packages that could be updated |
--deprecated |
Displays the packages that are marked as deprecated |
--include-transitive |
Displays the transitive packages in the result |
--framework <FRAMEWORK> |
Displays only the packages applicable for a specific target framework |
Example:
Running in the project folder with the option --outdated
> dotnet list package --outdated
Project '.\project.csproj' has the following package references with updates available -
'netstandard1.0'
Top-level Package Requested Resolved Latest
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.7.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.1.7-beta
'net45'
Transitive Package Requested Resolved Latest
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.7.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.1.7-beta
>
Behavior Clarification:
-
--outdatedwill consider the prerelease packages when looking for the latest package only if the requested version is a prerelease version or the option--include-prereleaseis used. For example,nuget.versioninghas a later prerelease package than4.7.0, but it is not shown in the result, whileSlowCheetah.Xdthas the latest prerelease in the result.
Example:
Running in the project folder with the option --deprecated
> dotnet list package --deprecated
Project '.\project.csproj' has the following deprecated package references -
'netstandard1.0'
Top-level Package Requested Resolved Suggested
> SlowCheetah.Xdt (D) 1.0.1-beta 1.0.1-beta 1.1.7-beta
'net45'
Transitive Package Requested Resolved Suggested
> SlowCheetah.Xdt (D) 1.0.1-beta 1.0.1-beta 1.1.7-beta
D: Deprecated packages
>
Behavior clarification:
- In the case of
--deprecatedand--outdatedbeing used together, the deprecated packages will be shown above the outdated packages, and will have(D)to indicate deprecation.
Example:
Running in the project folder with the option --include-transitive
> dotnet list package --include-transitive
Project '.\project.csproj' has the following package references -
'netstandard1.0'
Top-level Package Requested Resolved
> NETStandard.Library (A) 2.0.3 2.0.3
> nuget.versioning [4.0.0, 4.3.0) 4.0.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta
Transitive Package Resolved
> Microsoft.NETCore.Platforms 1.1.0
> Microsoft.CSharp 4.3.0
> Microsoft.Web.Xdt 2.1.2
> System.Collections 4.3.0
> System.ComponentModel.TypeConverter 4.3.0
> System.Diagnostics.Debug 4.3.0
> System.Diagnostics.Tools 4.3.0
> System.Globalization 4.3.0
> System.IO 4.3.0
> System.Linq 4.3.0
> System.Linq.Expressions 4.3.0
> System.Net.Primitives 4.3.0
> System.ObjectModel 4.3.0
> System.Reflection 4.3.0
> System.Reflection.Extensions 4.3.0
> System.Reflection.Primitives 4.3.0
> System.Resources.ResourceManager 4.3.0
> System.Runtime 4.3.0
> System.Runtime.Extensions 4.3.0
> System.Runtime.Serialization.Primitives 4.3.0
> System.Text.Encoding 4.3.0
> System.Text.Encoding.Extensions 4.3.0
> System.Text.RegularExpressions 4.3.0
> System.Threading 4.3.0
> System.Threading.Tasks 4.3.0
> System.Xml.ReaderWriter 4.3.0
> System.Xml.XDocument 4.3.0
'net45'
Top-level Package Requested Resolved
> NETStandard.Library (A) 2.0.3 2.0.3
> nuget.versioning [4.0.0, 4.3.0) 4.0.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta
Transitive Package Resolved
> Microsoft.NETCore.Platforms 1.1.0
> Microsoft.Web.Xdt 2.1.2
> System.Runtime.InteropServices.RuntimeInformation 4.3.0
A: Auto-referenced package
>
Behavior clarification:
- Transitive packages are not requested by the developer, as a result, they do not have a requested column.
-
--include-tranistivecould be used with other options like--outdatedand--deprecated.
Example:
Running in the project folder with the option --framework netstandard1.0
> dotnet list package --framework netstandard1.0
Project '.\project.csproj' has the following package references -
'netstandard1.0'
Top-level Package Requested Resolved
> NETStandard.Library (A) 2.0.3 2.0.3
> nuget.versioning [4.0.0, 4.3.0) 4.0.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta
A: Auto-referenced package
>
Behavior Clarification:
-
--frameworkwill support including multiple frameworks where each framework is separated by a,.
The following options might be included in the final version:
list package command option |
Behavior |
|---|---|
--include-prerelease |
Must be used only with --outdated present. Considers the prerelease versions when looking for latest |
--highest-patch |
Must be used only with --outdated present. Considers only up to the latest patch from the requested version when looking for latest |
--highest-minor |
Must be used only with --outdated present. Considers only up to the latest minor from the requested version when looking for latest |
--config <config file> |
Must be used only with --outdated present. Uses only the sources in the config file to check for updates |
--source <source name> |
Must be used only with --outdated present. Uses only the given source to look for updates |
Example:
Running in the project folder with the option --outdated --include-prerelease
> dotnet list package --outdated --include-prerelease
Project '.\project.csproj' has the following package references -
'netstandard1.0'
Top-level Package Requested Resolved Latest
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.8.0-preview1.5156
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.1.7-beta
'net45'
Top-level Package Requested Resolved Latest
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.8.0-preview1.5156
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.1.7-beta
>
Example:
Running in the project folder with the option --outdated --highest-patch
> dotnet list package --outdated --heighest-patch
Project '.\project.csproj' has the following package references -
'netstandard1.0'
Top-level Package Requested Resolved Latest patch
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.3.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.0.9-beta
'net45'
Top-level Package Requested Resolved Latest patch
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.3.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.0.9-beta
>
Example:
Running in the project folder with the option --outdated --highest-minor
> dotnet list package --outdated --highest-minor
Project '.\project.csproj' has the following package references -
'netstandard1.0'
Top-level Package Requested Resolved Latest minor
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.7.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.1.7-beta
'net45'
Top-level Package Requested Resolved Latest minor
> nuget.versioning [4.0.0, 4.3.0) 4.0.0 4.7.0
> SlowCheetah.Xdt 1.0.1-beta 1.0.1-beta 1.1.7-beta
>
Behavior clarification:
-
--highest-patchand--highest-minorwill be constrained by the patch and minor, repectively, of the requested version.
Show list packages in the solution
> dotnet list package
<Project name>
<List of packages>
--------------------------------------------------------
<Project name>
<List of packages>
--------------------------------------------------------
<Project name>
<List of packages>
Check out the proposals in the accepted & proposed folders on the repository, and active PRs for proposals being discussed today.