简体   繁体   中英

Using Nuget.VisualStudio how would I get a list of packages from a repository

When using the Nuget.VisualStudio Nuget package how do I get a list of package to allow the user to choose one to install?

I am migrating a vsix project that was built against the Visual Studio 2013 Nuget API to use the API for Visual Studio 2017. I am using this documentation to setup the Nuget service which has the following warning.

Do not use any other types besides the public interfaces in your code, and do not reference any other Nuget assemblies, including NuGet.Core.dll.

The Visual Studio 2013 vsix project used Nuget.Core to get the list of packages that could be installed. Unfortunately when I add Nuget.Core there are a ton of namespace collisions. This is the code we are using from the Nuget.Core package which I need to find an equivalent to in the new Nuget API.

 IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("http://ourfeed.net/nuget");
 List<IPackage> packages = repo.GetPackages().Where(p => p.Tags.Contains(tag))
           .OrderByDescending(p => p.Version)
           .Take(packagesPerTag).ToList();;

Using Nuget.VisualStudio how would I get a list of packages from a repository

According to the NuGet/NuGet2 :

NuGet2

This is the home of nuget.core and all the repos from codeplex. This repository is for Version 2 of NuGet. Version 3 of the Nuget client library has moved to Nuget.Client . See the NuGet API v3 documentation for more information.

See the NuGet API v3 documentation for more information NuGet Client SDK:

https://docs.microsoft.com/en-us/nuget/reference/nuget-client-sdk

And below are some blog posts that are more useful:

Check the similar thread for some more details.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM