获取 Nuget 软件包的发布日期

问题描述 投票:0回答:1

有没有办法获取 nuget 包的发布/发布日期?我搜索了 nuget 命令和 VS powershell 脚本,但一无所获。我什至在 nuget.org 上找不到它,它提供了诸如“一个月前”之类的抽象概念。

我更喜欢以编程方式检索此信息。但我会接受任何方式。

nuget
1个回答
1
投票

使用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}");
}
© www.soinside.com 2019 - 2024. All rights reserved.