在 VS2012 中添加 NuGet 包作为项目引用的最佳方法?

在 VS2012 中添加 NuGet 包作为项目引用的最佳方法?

问题描述:

好的.非常快的问题,我可能只是很厚.

Ok. Really quick question, I'm probably just being thick.

如果您右键单击项目的references"文件夹,然后单击Manage NuGet Packages",您就可以安装包,您单击的项目会自动引用它们.但是后来我想在同一解决方案中添加对其他项目的相同引用.如果您重复上一步但单击另一个项目,唯一的选择是卸载该包(因为它已安装),添加现有(已安装)NuGet 包作为项目引用的正确方法是什么?我是否要使用普通对话框添加引用并浏览"到包文件夹中的 dll?使用一种方法添加第一个引用然后另一个用于后续引用?这似乎不对.

If you right-click on a projects 'references' folder then 'Manage NuGet Packages' you can then install packages and they are automatically referenced by the project you clicked on. But then I want to add the same reference to other projects in the same solution. If you repeat previous but click on another project the only option is to uninstall the package (since it's already installed), what is the proper way to add an existing (already installed) NuGet package as a project reference? Am I to add the reference using the normal dialog and 'browse' to the dll in the packages folder? Use one method to add the first reference then another for subsequent references? That doesn't seem right.

您可以使用Manage NuGet package for Solution...:

  • 右键单击解决方案
  • 工具>库包管理器管理解决方案的 NuGet 包

然后您可以选择在哪些项目中安装包,如下面的屏幕截图所示:此外,您可以使用相同的 Manage NuGet packages for Solution... 将已安装的包添加到解决方案中的另一个项目.

Then you can choose in which projects install package as on screenshot below: Additionally you can add installed package to another projects in solution using the same Manage NuGet packages for Solution....