是否应将project.lock.json文件签入源代码管理?(ASP.NET Core 1.0) [英] Should project.lock.json file be checked into source control? (ASP.NET Core 1.0)

查看:64
本文介绍了是否应将project.lock.json文件签入源代码管理?(ASP.NET Core 1.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP.NET Core 1.0,将 project.lock.json 文件检入源代码管理是最佳实践吗?

Using ASP.NET Core 1.0, is it best practice to check in the project.lock.json file into source control?

推荐答案

简短答案:否,不应将project.lock.file检入源代码控制-您应将版本控制系统配置为忽略它(即,如果使用git,则将其添加到.gitignore中).

Short answer: No, project.lock.file should not be checked into source control - you should configure the version control system to ignore it (i.e. add it to .gitignore if you're using git).

长答案:project.lock.json包含项目整个依赖树的快照-不仅是依赖"部分中列出的程序包,还包括这些依赖关系的所有已解决依赖关系,依此类推.但这不像ruby的 Gemfile.lock .与Gemfile.lock不同,project.lock.json不会告诉 dotnet restore 应该恢复哪些确切版本的软件包-它只会被覆盖.因此,应将其视为缓存文件,并且切勿将其检入源代码管理中.

Long answer: The project.lock.json contains a snapshot of project's whole dependency tree - not just packages listed in "dependencies" sections, but also all resolved dependencies of those dependencies, and so on. But it is not like ruby's Gemfile.lock. Unlike Gemfile.lock, project.lock.json doesn't tell dotnet restore which exact versions of packages should be restored - it simply gets overwritten. As such, it should be treated like a cache file and never be checked into source control.

如果将其签入版本控制,则很可能在其他计算机上:

If you check it into version control, then most probably on other machine:

  • dotnet 会认为所有软件包都已还原,但实际上某些软件包可能会丢失并且构建会失败,而不会提示开发人员运行 dotnet restore
  • project.lock.json将在 dotnet恢复期间被覆盖,并且在大多数情况下将与源代码控制中存储的版本不同.因此几乎在每次提交中都会对其进行修改
  • project.lock.json将在合并过程中引起冲突
  • dotnet will think that all packages are restored, but in fact some packages might be missing and the build will fail, without hinting the developer to run dotnet restore
  • project.lock.json will be overwritten during dotnet restore and in most cases will be different than the version stored in source control. So it will be modified in almost every commit
  • project.lock.json will cause conflicts during merge

这篇关于是否应将project.lock.json文件签入源代码管理?(ASP.NET Core 1.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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