How to use IVsPackageSourceProvider
can I get a list of NuGet sources, like a https://www.nuget.org/api/v2/
? I try to use just such a structure:
using (Microsoft.VisualStudio.Shell.ServiceProvider provider = new Microsoft.VisualStudio.Shell.ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)base._dteObject))
{
IComponentModel service = (IComponentModel)provider.GetService(typeof(SComponentModel));
try
{
var sourceProvider = service.GetService<IVsPackageSourceProvider>();
}
catch(Exception ex)
{
}
}
But Try
block raises an Exception
with the text:
Cannot cast the underlying exported value of type 'NuGet.VisualStudio.VsPackageSourceProvider (ContractName="NuGet.VisualStudio.IVsPackageSourceProvider")' to type 'NuGet.VisualStudio.IVsPackageSourceProvider'
Please tell me how to use this provider.
Sry for bad english
You can get the list of packages NuGet via IVsPackageInstallerServices, like this:
Edit:
Code: https://1drv.ms/u/s!AlvaNEnglADDe3a-mSTWubSix-w