如何使用.NET CLI列出所有已安装的NuGet软件包和版本
如何在没有Visual Studio 2017的ASP.NET Core项目中使用.NET Core CLI列出所有本地安装的NuGet软件包?
How to list all locally installed NuGet packages using .NET Core CLI in a ASP.NET Core project without Visual Studio 2017?
我有一个ASP.NET Core 2.1项目。默认情况下,我有一个< PackageReference Include = Microsoft.AspNetCore.App />
,其中没有版本。我想知道它使用的是什么版本。我找不到任何CLI命令来查询该信息。
I have a ASP.NET Core 2.1 project. I have a <PackageReference Include="Microsoft.AspNetCore.App" />
by default that don't have a Version in it. I'd like to know what's the Version it used. I can't find any CLI command to query that information.
如果版本$ c没有提供metapackage的$ c>属性(
Microsoft.AspNetCore.App
是),采用本地安装的最低版本。您可以在%userprofile%\.nuget\packages\microsoft.aspnetcore.app
If Version
attribute for metapackage (which Microsoft.AspNetCore.App
is) is not supplied, the lowest locally installed version is taken. You can check which versions you have installed locally in %userprofile%\.nuget\packages\microsoft.aspnetcore.app
但是,您通常不想知道metapackage的版本,但是要知道其中每个软件包的版本,您可以通过以下方式确定它们:
However, you usually don't want to know metapackage version, but a version of each package in it and you can determine them by:
var referencedAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
foreach (var assembly in referencedAssemblies)
Console.WriteLine($"{assembly.Name} {assembly.Version}");