有没有办法获取 nuget 包的发布/发布日期?我搜索了 nuget 命令和 VS powershell 脚本,但一无所获。我什至在 nuget.org 上找不到它,它提供了诸如“一个月前”之类的抽象概念。
我更喜欢以编程方式检索此信息。但我会接受任何方式。
使用NuGet SDK。我修改了代码以显示
Published
属性。
ILogger logger = NullLogger.Instance;
CancellationToken cancellationToken = CancellationToken.None;
SourceCacheContext cache = new SourceCacheContext();
SourceRepository repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json");
PackageMetadataResource resource = await repository.GetResourceAsync<PackageMetadataResource>();
IEnumerable<IPackageSearchMetadata> packages = await resource.GetMetadataAsync(
"Newtonsoft.Json", // replace with the required package id
includePrerelease: true,
includeUnlisted: false,
cache,
logger,
cancellationToken);
foreach (IPackageSearchMetadata package in packages)
{
Console.WriteLine($"Version: {package.Identity.Version}");
Console.WriteLine($"Publish date: {package.Published}");
}