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", includePrerelease: true, includeUnlisted: false, cache, logger, cancellationToken);foreach (IPackageSearchMetadata package in packages){ Console.WriteLine($"Version: {package.Identity.Version}"); Console.WriteLine($"Listed: {package.IsListed}"); Console.WriteLine($"Tags: {package.Tags}"); Console.WriteLine($"Description: {package.Description}");}
This code is written in C#. The logger attribute inside the IEnumerable
throws an error. Also, and more important it gets stuck on the first line of code with await
:
PackageMetadataResource resource = await repository.GetResourceAsync<PackageMetadataResource>();
It gets there, but the await never closes.
Does anyone knows how to fix this? Did anyone have this problem before?
This is the official SDK link: https://learn.microsoft.com/en-us/nuget/reference/nuget-client-sdk
I want to solve the problems so it does not get stuck and returns the expected example output