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

查看:111
本文介绍了是否应将.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-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天全站免登陆