Getting release date of Nuget packages

Viewed 288

Is there a way to get the release/published dates of nuget packages? I've searched the nuget commands and VS powershell scripts but am coming up empty. I can't even find it on nuget.org, which gives abstractions like 'one month ago' instead.

I would prefer a programmatic way to retrieve this info. But I'll settle for any way at all.

1 Answers

Use the NuGet SDK. I've modified the code to display the Published property.

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}");
}
Related