What is project.lock.json?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
project.lock.json was the dependency lock file generated by the early project.json era of .NET Core tooling. Its job was to record the exact package graph chosen during restore so builds stayed predictable across machines, target frameworks, and runtimes.
What the File Was For
In the old .NET Core workflow, developers described dependencies in project.json. When dotnet restore or a NuGet restore ran, the tool resolved every direct and transitive dependency and wrote the result to project.lock.json.
That generated file captured details such as:
- The exact version selected for each package
- The target framework the package applied to
- Runtime-specific assets when a runtime identifier was involved
- Whether a dependency came from another project or from a package feed
The key point is that project.lock.json was not the place where you declared intent. It was the place where restore recorded the resolved result.
Here is a simplified example of an old project.json file:
After restore, the lock file expanded that short declaration into a full dependency graph. A generated file might include package names, resolved versions, and framework-specific sections that made restore deterministic for the next build.
Why It Mattered
Without a lock file, two restores performed at different times could resolve slightly different transitive dependencies. That can produce hard-to-reproduce bugs, especially when a dependency range allows newer versions. project.lock.json reduced that uncertainty by pinning what restore had already chosen.
The workflow looked like this:
dotnet build depended on the resolved package graph already written by restore. If the dependency declaration changed, restore regenerated the lock file.
This also helped with multi-targeted projects. If one project targeted more than one framework, the lock file kept separate dependency information for each target. That mattered because a package might expose different assemblies for net451, netcoreapp1.0, or other targets.
Generated File, Not Hand-Written Config
A common mistake was treating project.lock.json like a configuration file. It was not intended for manual editing. Even if you changed a version in the lock file, the next restore would overwrite it based on project.json and feed resolution rules.
If you wanted a different package version, you changed the declaration and then restored again:
Then:
The important mental model is simple:
- '
project.jsondescribed what your project wanted' - '
project.lock.jsonrecorded what restore actually resolved'
What Replaced It
Modern SDK-style .NET projects do not use project.lock.json. When Microsoft moved from project.json to *.csproj plus PackageReference, the tooling shifted to files such as obj/project.assets.json. In newer workflows you may also see packages.lock.json, which serves a more explicit lock-file role.
For example, a modern project typically declares packages in the project file:
So if you are searching a current repository and cannot find project.lock.json, that usually means the project uses the newer SDK-style build system instead of the older project.json stack.
Common Pitfalls
- Editing
project.lock.jsonby hand. Restore regenerates it, so the change does not persist in a reliable way. - Confusing it with
project.assets.jsonorpackages.lock.json. They belong to newer restore models and are not interchangeable. - Assuming its presence in all .NET projects. It is tied to an older tooling generation, not modern SDK-style projects.
- Chasing package bugs in the wrong file. Dependency intent lives in
project.jsonor*.csproj, not in the generated lock output.
Summary
- '
project.lock.jsonwas the generated dependency lock file for olderproject.json-based .NET Core projects.' - It stored the resolved package graph, including transitive dependencies and framework-specific results.
- The file supported reproducible restores and builds across environments.
- Developers generally should not edit it by hand.
- Modern .NET projects usually use
project.assets.jsonand optionallypackages.lock.jsoninstead.
Related reading
- What is recommended way to perform async tasks in WPF?
- what is reflection in C, what are the benefit. How to use it to get benifit
- What is Serializable and when should I use it?
- What is the ?? syntax in C?
- What is the App_Data folder used for in Visual Studio?
- What is the basic concept behind WaitHandle?
- What is the best algorithm for overriding GetHashCode?
- What is the best algorithm for overriding GetHashCode?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.