应该将 .nuget 文件夹添加到版本控制中吗? [英] Should .nuget folder be added to version control?

查看:33
本文介绍了应该将 .nuget 文件夹添加到版本控制中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用较新版本的 NuGet,可以将项目配置为自动恢复 NuGet 包,以便 packages 文件夹不需要包含在源代码存储库中.不错.

With newer versions of NuGet it is possible to configure a project to automatically restore NuGet packages so that the packages folder doesn't need to be included in the source code repository. Good.

但是,此命令添加了一个新的 .nuget 文件夹,并且那里有一个二进制文件 NuGet.exe.这也可以由 Visual Studio 自动重新创建,因此将其添加到版本控制中感觉不正确.但是,如果没有此文件夹,Visual Studio 甚至无法正确加载解决方案.

However, this command adds a new .nuget folder and there is a binary there, NuGet.exe. This can also be re-created automatically by Visual Studio and so it doesn't feel correct to add that to version control. However, without this folder Visual Studio won't even load the solution properly.

你们是如何处理这个问题的?将 .nuget 添加到源代码管理?在打开解决方案之前运行一些命令行脚本?

How do you people deal with this? Add .nuget to source control? Run some command line script before opening the solution?

推荐答案

这篇文章很旧,你不应该再使用解决方案级别的 NuGet 包还原.从 2.7+ 版本开始,NuGet 设置中有一个选项可以在构建时自动恢复包.因此可以删除 .nuget 文件夹并从项目中删除该选项.

This post is old, you should not be using solution level NuGet package restore anymore. As of version 2.7+ there is an option in the NuGet setup to automatically restore packages on build. So the .nuget folder can be deleted and the option removed from your projects.

http://docs.nuget.org/docs/reference/package-restore

更新:随着 NuGet 4.x 和 .NET Standard 2.0 的发布,当您使用新的 csproj 格式时,您现在可以使用包引用,具有讽刺意味的是重新引入对 msbuild 的依赖来恢复包,但现在包是 msbuild 的一等公民.上面的链接也提到了 PackageReference,但下面的公告更详细地说明了它:

UPDATE: With the release of NuGet 4.x and .NET Standard 2.0, when you use the new csproj format you can now use package references, ironically reintroducing the dependency on msbuild to restore packages, but now packages are a first class citizen of msbuild. The link above also makes mention of the PackageReference, but the following announcement details it better:

https://blog.nuget.org/20170316/NuGet-now-fully-integrated-into-MSBuild.html

还有 NuGet 4.x RTM 公告,讽刺的是它没有那么有用:

And the NuGet 4.x RTM announcement, which ironically isn't as useful:

https://blog.nuget.org/20170308/Announcing-NuGet-4.0-RTM.html

更新 2: 显然,在 VS2017 中,您甚至可以将包引用与经典 csproj 项目一起使用,但它们不再向后兼容,并且在恢复包子依赖项方面存在一些问题.我相信这一切都会得到解决.

UPDATE 2: Apparently with VS2017 you can even use package references with classic csproj projects, but they aren't backwards compatible anymore, and there have been some problems with restoring package sub-dependencies. I'm sure that will all be resolved.

这篇关于应该将 .nuget 文件夹添加到版本控制中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆