I need to get the Release Notes stored in the metadata. This code seems to be able to read the metadata, however i dont know how to get to the release notes.
using NuGet.Common;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
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(
    "Flexygo",
    includePrerelease: true,
    includeUnlisted: false,
    cache,
    logger,
    cancellationToken);
i am trying to get a String with the release notes using only the official SDK
You can achieve the above using the Library NuGet.Client. Install the following library using your Nuget package manager console via the below code :
Install-Package NuGet.Client
If not you can alter your own code as per below to print all information extracted :
using NuGet.Common;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using System.Reflection;
class Program
{
    static async Task Main()
    {
        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(
            "Flexygo",
            includePrerelease: true,
            includeUnlisted: false,
            cache,
            logger,
            cancellationToken);
        foreach (var package in packages)
        {
            var packageMetadata = await resource.GetMetadataAsync(package.Identity, cache, logger, cancellationToken);
            var v = await packageMetadata.GetDeprecationMetadataAsync();
            Console.WriteLine("------------------------------------------------------------------");
            Console.WriteLine("Package Metadata: " + packageMetadata.Title.ToString());
            Type t = packageMetadata.GetType();
            PropertyInfo[] pi = t.GetProperties();
            foreach (PropertyInfo p in pi)
            {
                System.Console.WriteLine(p.Name + " : " + p.GetValue(packageMetadata));
            }
            Console.WriteLine("------------------------------------------------------------------");
        }
    }
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With