问题
How to list all locally installed NuGet packages using .NET Core CLI in a ASP.NET Core project without Visual Studio 2017?
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.
回答1:
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
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}");
来源:https://stackoverflow.com/questions/51698022/how-to-list-all-installed-nuget-packages-and-versions-using-net-cli