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://learn.microsoft.com/en-us/nuget/reference/nuget-client-sdk
And below are some blog posts that are more useful:
Exploring the NuGet v3 Libraries, Part 1: Introduction and concepts
Exploring the NuGet v3 Libraries, Part 2: Searching for packages
Exploring the NuGet v3 Libraries, Part 3: Installing packages
Check the similar thread for some more details.
Hope this helps.