Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

How to list details of all nuget packages cached in the feed



  • Hi,

    How can I list all the packages, versions, description and license URL's from a feed - but only for the packages that's are cached via proget and not all those in the connectors..

    Ideally a CSV type list so can view in excel.

    Many Thanks

    Gary

    Product: ProGet
    Version: 3.8.0



  • You can query the ProGet database directly, or use the [NuGetPackages_GetPackages] API method, which returns [NuGetPackages_Extended]. If [Cached_Indicator] is 'Y', then it's cached.



  • Could you please provide some more information on this please - I'm using C# and my NuGet feed uses LDAP authentication.

    I decided to try the following using the ProGet SDK with something like this...

      Inedo.NuGet.Packages.NuGetFeed feed = new Inedo.NuGet.Packages.NuGetFeed("http://nuget/nuget/ThirdParty", new NetworkCredential("User","Pass"));
                var results = feed.Query(new Inedo.NuGet.Packages.PackageQueryOptions() {  });
    
                foreach(var r in results)
                {
                    var props = r.GetAllProperties();
                }
    

    As I'm using LDAP authentication I keep getting authentication errors - (obviously with a real username and password), also can I pass in the packagequeryoption a filter for only cached packages?

    Thanks again

    Gary



  • The Inedo.NuGet library is an alternate NuGet API client, more-or-less a replacement for the NuGet.Client library from Microsoft. Though you're welcome to use it, it's officially supported as part of the SDK, and it's really just intended for internal Inedo use (so it's not so well documented).

    That said, note that the NuGet API has no concept of a "cached packages", so I don't think this will help all that much. The NuGet API is also a total pain (it's ODATA based), so I suggest just using PRoGet's API methods (mentioned above) to get basic package details.

    If you want to access this via the SDK, you can use the "StoredProcs" static class to access the API methods.



  • Hi

    Yes I prefer to use the api than an DB direct access, so ill try with the ProGet SDK - and it look like this is what I needed.

    What's odd I cant get past the authentication issue I mentioned - I'm using NetworkCredential and our feed is LDAP protected, so I used fiddler to find out more information and then it works! So clearly it is re-writing the authentication headers, but this then begs the question why does providing a NetworkCredential class to NuGetFeed return a 401 error? I've tried all variations i.e. with/without domain etc.

    Any ideas?

    And lastly can I provide in the packagequeryoptions just to return cached packages and not those via the connectors?

    Thanks



  • You say LDAP, but I suspect you mean Windows Integrated Authentication? That's kinda complex to interact with, but I suspect you'll want to use WindowsIdentity.GetCurrent() instead of NetworkCredentials (which are Basic).

    I'm not familiar enough with the Inedo.NuGet library, but I believe it only works with "NuGet Feeds", which have no concept of "cached or connected packages," so those may not work as a package query option.



  • Ok yes windows integrated authentication - as we have turned on the AD integration in ProGet.

    The class NuGetFeed only takes a ICredentials not WindowsIdentity. Any other suggestion?

    Thanks

    Gary



  • I'm not sure; only a few of us here are familiar w/ that library, so I'll leave this quesiton open and see if another engineer can answer.

    But like I said, I do suggest using either the ProGet API, or the StoredProcs class under Inedo.ProGet.Data (which is essentially the same thing), to get this iinformation.



  • If you just either use the NuGetFeed constructor that does not take credentials, or set the credentials parameter to null, then it will attempt to use Windows Authentication for the current user.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation