nuget - checkin nuget包

标签 nuget source-control-explorer

我的应用程序几乎没有 nuget 包引用。我是否应该将 packages 文件夹也 checkin 到源代码管理中?我的目的是让其他开发人员可以使用源代码,并跟上稳定版本的引用。如果我使用最新的 nuget 更新更新了项目并且应用程序崩溃了,我想从源代码管理中获取特定版本的 depedable dll 的日期。

或者我应该创建一个library文件夹并从packages文件夹中删除dll并检查我之前所做的事情?并仅在本地管理packages文件夹?

最佳答案

您必须权衡是否将 NuGet 包纳入源代码管理的利弊并自行决定。选择完全取决于您。

I want to get a particular version of the dependable dlls from the Source Control for a date if I have updated the project with the latest nuget updates and the app breaks.

这两种方法都支持。如果您不 checkin NuGet 包,则应 checkin 每个项目的packages.config 文件。此文件记录所使用的 NuGet 包的版本。因此,您可以 checkout 旧版本的源代码,它将使用旧版本的 NuGet 包。 nuget.org 上的 NuGet 包永远不会被删除。

NuGet 网站有 documentation on the reasons您可能不想省略我在此处引用的源代码管理中的包:

Distributed version control systems (DCVS) include every version of every file within the repository, and binary files that are updated frequently can lead to significant repository bloat and more time required to clone the repository. With the packages included in the repository, team members may add references directly to package contents on disk rather than referencing packages through NuGet. It becomes harder to "clean" your solution of any unused package folders, as you need to ensure you don't delete any package folders still in use.

构建服务器或网络连接有限时,可能会出现未将 NuGet 包 checkin 源代码管理的问题。在构建服务器上,您需要访问互联网,或者提供包含项目正在使用的 NuGet 包的本地目录。此外,您还需要在构建项目之前运行 NuGet.exe Restore 或使用基于 MSBuild 的包恢复(已被 NuGet 团队弃用)。请注意,如果您在 Visual Studio 中使用最新版本的 NuGet,则在生成项目时会自动恢复 NuGet 包。其他 IDE 具有类似的功能,或者至少有一种无需从命令行使用 NuGet.exe 即可恢复包的方法。

将 NuGet 包置于源代码管理中的好处是,您不依赖于 NuGet,其他开发人员可以获取源代码并使用它,而无需恢复任何 NuGet 包。

请注意,将 dll 移至库文件夹意味着您无法充分利用 NuGet。 NuGet 期望 dll 位于 packages 目录中,所有引用都指向此目录中的 dll,因此将 dll 移动到库文件夹中意味着您将无法使用 NuGet 来更新项目。

要考虑的方法是:

  1. 将包目录检查到源代码管理中。
  2. 不要将包目录 checkin 源代码管理并依赖 NuGet 恢复包。
  3. 根本不要使用 NuGet。将二进制文件放在单独的目录中,并检查到源代码管理中。

关于nuget - checkin nuget包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25467245/

相关文章:

asp.net-mvc - NuGet 项目 > 添加库包引用未出现

NuGet 包还原无法使用自定义源提示输入凭据

visual-studio - VS2012 - 在特定项目/节点打开源代码管理资源管理器

.net - yarn、grunt、npm、bower 和 nuget 包管理器有什么区别?

c# - Nuget 安装包成功但未向 csproj 添加引用

nuget - 如何告诉 NuGet 为每个项目安装包而不是解决方案

如果手动添加项目且未包含在 vs2015 解决方案中,TFS 不会跟踪更改

git - Git 使用的 merge 冲突语法有名称吗?

tfs - 如何真正重置每个设置并删除tfs中的所有项目(在Web门户中)