What is project.lock.json?

懵懂的女人 提交于 2019-12-03 01:58:22

Update: project.json has been replaced with .csproj as the main project file for .NET Standard projects. This question refers to the old system before the introduction of PackageReference in NuGet 4.0.

You may still occasionally see project.lock.json as an artifact of the build process, but it should be ignored. Managing the NuGet packages that your .NET Standard/.NET Core project depends on should always be done by either

  • Editing the .csproj file directly
  • Using the dotnet CLI (dotnet add package, etc)
  • Using the Package Manager GUI if you're using Visual Studio

Old answer for posterity: project.lock.json is generated by the .NET tooling when you restore the project's packages. You shouldn't touch it or check it into source control. Edit project.json directly.

During the package restore process (dotnet restore), NuGet has to analyze the dependencies in your project, walk their dependency graphs, and figure out what packages should be installed for your project and your project's dependencies.

This is a non-trivial amount of work, so the results are cached in project.lock.json to make subsequent restores faster and more efficient. The lock file will be regenerated if project.json is modified and dotnet restore is executed again.

Every so often, in our team, when someone updates some nuget, we have the same problem, the lock.json files doens't get updated, even running dotnet restore so, before applying the last choice (deleting them) I suggest run grunt from your command line. If that doesn't work, delete all the lock.json files and run dotnet restore, this is my favourite choice ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!