Closed KirillOsenkov closed 3 years ago
I wasn't able to find documentation for ListResource so perhaps worth adding to the docs as well?
ListResource is V2 based, it always falls back to the search/packages OData endpoint. That's really the reason why we haven't documented it and instead recommend the other 3 resources (Search, Metadata, FindPackagesById).
Those are capable of switching between implementations properly.
I started writing this before Nikolche replied, but I was too slow because I was checking some server implementations and getting links:
This only works for v3 feeds when the service index contains a LegacyGallery
link, as it's fundamentally a v2 operation.
While nuget.org, Azure DevOps, and MyGet implement it, I know that Sleet and BaGet do not. I don't know about GitHub Package Repository, or all the other servers listed in NuGet doc's hosting a package page.
A Nikolche wrote, that sample will not work for all NuGet server implementations.
So is there a canonical way to do this properly for any feed? Or should we publish this with a disclaimer explaining that it's only for feeds that support V2, and won't work in certain servers such as Sleet and BaGet?
There's no resource to list all package ids in v3 today. https://github.com/NuGet/NuGetGallery/issues/3878 is the ask afaik.
Then let's add this sample and add a snippet in the docs clarifying the situation. It's useful in most scenarios and better than nothing.
There's no resource to list all package ids in v3 today. NuGet/NuGetGallery#3878 is the ask afaik.
FYI, some V3 servers like nuget.org provide a catalog resource which can be used to discover all packages (see this tutorial). Here's a tool I wrote to do exactly just that: https://github.com/loic-sharma/nuget-mirror
For NuGet servers that do not support V2 and the catalog resource, I would recommend falling back to the search resource.
So let's see if I'm getting this right.
ListResource
as used in my sample aboveSo there's no reliable way to do what I want for all feeds but some combination of ListResource and catalog resource can together provide it for most feeds.
Does this sound about right?
That's right. For scenario 4, this suggestion can be used:
For NuGet servers that do not support V2 and the catalog resource, I would recommend falling back to the search resource.
In hindsight, this may be a little too complex for the SDK samples 😅
Let's either merge this or close it, and I'm OK with either :) Thanks!
@loic-sharma @nkolev92