Search code examples
packagenugetlockingrestore

Schema of nuget packages.lock.json file generated by locking dependencies during restore


I can enable the packages.lock.json files to be generated as described in this link: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#locking-dependencies

An example packages.lock.json file may look like this:

{
  "version": 1,
  "dependencies": {
    ".NETCoreApp,Version=v3.1": {
      "Microsoft.NETFramework.ReferenceAssemblies": {
        "type": "Direct",
        "requested": "[1.0.0, )",
        "resolved": "1.0.0",
        "contentHash": "7D2TMufjGiowmt0E941kVoTIS+GTNzaPopuzM1/1LSaJAdJdBrVP0SkZW7AgDd0a2U1DjsIeaKG1wxGVBNLDMw=="
      },
      "Newtonsoft.Json": {
        "type": "Direct",
        "requested": "[12.0.3, )",
        "resolved": "12.0.3",
        "contentHash": "6mgjfnRB4jKMlzHSl+VD+oUc1IebOZabkbyWj2RiTgWwYPPuaK1H97G1sHqGwPlS5npiF5Q0OrxN1wni2n5QWg=="
      }
    }
  }
}

Is there documentation around the schema of this file and what it means? I notice fields like type, resolved, contentHash, etc. under the dependencies node.

Sometimes the nodes might follow these patterns:

"Microsoft.Win32.Primitives": {
        "type": "Transitive",
        "resolved": "4.3.0",
        "contentHash": "9ZQKCWxH7Ijp9BfahvL2Zyf1cJIk8XYLF6Yjzr2yi0b2cOut/HQ31qf1ThHAgCc3WiZMdnWcfJCgN82/0UunxA==",
        "dependencies": {
          "Microsoft.NETCore.Platforms": "1.1.0",
          "Microsoft.NETCore.Targets": "1.1.0",
          "System.Runtime": "4.3.0"
        }
      }

or

"somenameclient": {
        "type": "Project",
        "dependencies": {
          "SomeNameClientLib": "1.0.0",
          "RRRBase": "1.0.0"
        }
}

Solution

  • From what I can tell, they have not created or posted a .json schema file for the format of the NuGet packages.lock.json file. The official documentation here makes no mention of it.

    The closest thing you will get are:

    ...from the above link.