简体   繁体   English

在源代码上找不到IVsPackageInstaller软件包

[英]IVsPackageInstaller package not found on source

I am installing a nuget package programmatic-ally. 我正在以编程方式安装nuget软件包。 I have 2 nuget sources src1 and src2. 我有2个nuget源src1和src2。 MyNugetPackage had some dependencies AAA and BBB. MyNugetPackage有一些依赖项AAA和BBB。 MyNugetPackage is available via src1 and AAA and BBB are available via src2. MyNugetPackage可通过src1获得,AAA可通过src2获得。 I am getting error package AAA and BBB found on source src1. 我在源src1上发现错误包AAA和BBB。 How can I make the InstallPackage package install MyNugetPackage from src1 and AAA BBB from src2? 如何使InstallPackage软件包从src1安装MyNugetPackage,从src2安装AAA BBB? I have specifies "All" is source. 我已指定“全部”为来源。

var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));

var installerServices = componentModel.GetService<IVsPackageInstallerServices>();
var installer = componentModel.GetService<IVsPackageSourceProvider>();
installer.InstallPackage("All", project, "MyNugetPackage", (Version)null, false);

I tried to install from Package Manager Console and got the following error even though AAA.2.0.0 and BBB.2.0.0 are present in the folder c:\\users\\user\\Source\\Repos\\Testpro\\packages: 我尝试从软件包管理器控制台进行安装,即使文件夹c:\\ users \\ user \\ Source \\ Repos \\ Testpro \\ packages中存在AAA.2.0.0和BBB.2.0.0,也会出现以下错误:

Install failed. 安装失败。 Rolling back... Package 'MyNugetPackage.5.6.1.7358 : AAA [2.0.0, ), BBB [2.0.0, )' does not exist in project 'Testpro' Package 'MyNugetPackage.5.6.1.7358 : AAA [2.0.0, ), BBB [2.0.0, )' does not exist in folder 'c:\\users\\user\\Source\\Repos\\Testpro\\packages' 正在回滚...包'MyNugetPackage.5.6.1.7358:AAA [2.0.0,),BBB [2.0.0,)'在项目'Testpro'中不存在包'MyNugetPackage.5.6.1.7358:AAA [2.0.0 ,),BBB [2.0.0,)'在文件夹'c:\\ users \\ user \\ Source \\ Repos \\ Testpro \\ packages'中不存在

IVsPackageInstaller package not found on source 在源代码上找不到IVsPackageInstaller软件包

To my knowledge, NuGet Visual Studio extension 3.x and above does not have support for the "All" source. 据我所知,NuGet Visual Studio扩展3.x及更高版本不支持“全部”源。 This functionality did exist in NuGet 2.x. NuGet 2.x中确实存在此功能。 So the "All" keyword has no special meaning in the 3.x NuGet Visual Studio extension. 因此,在3.x NuGet Visual Studio扩展中,“全部”关键字没有特殊含义。

To resolve this issue, you can try to " null " source instead of " All ". 要解决此问题,您可以尝试将“ null ”源而不是“ All ”源。 Using null is the recommended way of installing a package from the user's configured package sources. 建议使用null从用户配置的软件包源中安装软件包。

See the similar issue on GitHub for some more detailed info. 有关更多详细信息,请参见GitHub上类似问题

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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