简体   繁体   English

VisualStudio 2013列出了所有NuGet包

[英]VisualStudio 2013 list all NuGet packages

I have a mvc 5 web project with a number of NuGet packages installed (like email, log, pagedlist etc). 我有一个mvc 5 web项目,安装了许多NuGet包(如电子邮件,日志,页面列表等)。

In a new similar project I would like to install the same NuGet packages. 在一个新的类似项目中,我想安装相同的NuGet包。 How can I in the old project list all installed NuGet packages? 如何在旧项目列表中安装所有已安装的NuGet包?

  1. You can find a packages.config file in the old project's root directory. 您可以在旧项目的根目录中找到packages.config文件。
  2. You can copy it to the new project. 您可以将其复制到新项目。
  3. If you go to Tools -> NuGet Packet Manager -> Packet manager settings and check Allow NuGet to download missing packages and the other check box that states Automatically check for missing packages during build in Visual Studio it will download it for you next time you build. 如果您转到工具 - > NuGet数据包管理器 - >数据包管理器设置并选中Allow NuGet to download missing packages ,另一个复选框表明Automatically check for missing packages during build in Visual Studio它将在您下次构建时为您下载。

If you want to list all installed nuget packages for the project take a look at this one. 如果要列出项目的所有已安装的nuget包,请看一下这个。

http://blogs.msdn.com/b/david_kidder/archive/2014/08/19/micro-blog-how-to-list-installed-nuget-packages-from-package-manager-console-and-be-able-to-read-them.aspx http://blogs.msdn.com/b/david_kidder/archive/2014/08/19/micro-blog-how-to-list-installed-nuget-packages-from-package-manager-console-and-be-能够阅读,them.aspx

You might also want to enable nuget package restore to restore the packages when rebuilding your project/s. 您可能还希望启用nuget包还原以在重建项目时还原包。 Here's another link for you - http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html 这是您的另一个链接 - http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

  1. In the root folder of your original project find a packages.config file. 在原始项目的根文件夹中找到packages.config文件。 Copy its contents to your new project, same file name. 将其内容复制到您的新项目,相同的文件名。
  2. Go to Visual Studio > Tools > Package Manager Settings > General 转到Visual Studio>工具>程序包管理器设置>常规
  3. Enable "Allow Nuget to download..." and "Automatically check for missing..." 启用“允许Nuget下载...”和“自动检查丢失...”

Now build your new project 现在建立你的新项目

Most of the answers here are partially correct. 这里的大部分答案都是部分正确的。

The first part is true. 第一部分是真的。 The packages.config file lists all packages that are used by the project. packages.config文件列出了项目使用的所有包。

However, all the answers about using Package Restore are incorrect. 但是,有关使用程序包还原的所有答案都不正确。 Package Restore will download any missing packages, however it is NOT the same as installing a package into a project. 包还原将下载任何缺少的包,但它是一样的安装包到项目。 It will not add references, run any install.ps1 scripts, or add files, modify .config, etc. Package Restore simply downloads missing packages. 它不会添加引用,运行任何install.ps1脚本,或添加文件,修改.config等.Package Restore只会下载丢失的包。 It is assumed that the packages were already installed to the project. 假设包已经安装到项目中。

In order for the packages to be correctly installed in your new project, open the Package Manager console, then type: 要在新项目中正确安装软件包,请打开软件包管理器控制台,然后键入:

Update-Package -ProjectName MyProjectName -Reinstall

This will force NuGet to run through the install process and correctly install the package into your project. 这将迫使NuGet运行安装过程并正确地将软件包安装到您的项目中。

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

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