Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is and how to select the type of dependency in project.json

I cannot find information about what is the difference between "build" and "platform" (and maybe some other) types of dependency, and what is the default type.

As example, I can add dependency using

"Microsoft.Extensions.JsonParser.Sources": "1.0.0"

or

"Microsoft.Extensions.JsonParser.Sources": {
  "type": "build",
  "version": "1.0.0"
},

or

"Microsoft.Extensions.JsonParser.Sources": {
  "type": "platform",
  "version": "1.0.0"
},

So how to choose? Official documentation does not contain information about this yet.

like image 943
Set Avatar asked Jun 29 '16 15:06

Set


Video Answer


1 Answers

I would suggest avoiding manually editing this file by hand, this way you avoid having to concern yourself with it too much. Additionally, there are plans to remove it entirely - such that you will no longer even use a project.json file to define dependencies. According to the JSON SchemaStore definition of the project.json, the type key is defined as such:

"type": {
    "type": "string",
    "default": "default",
    "enum": [ "default", "build", "platform" ]
  • build = a dependency that is only required for the building of the project, build-time dependency

  • platform = a dependency that is expected to reside on the platform in which your project is configured to target.

The type "platform" property on that dependency means that at publish time, the tooling will skip publishing the assemblies for that dependency to the published output.

If you examine the source for the ProjectReader.cs in the dotnet repo you will see how it serializes this JSON to an object, and in this object we can find the meaning (detailed above).

Additional reading

  • https://docs.microsoft.com/en-us/dotnet/articles/core/app-types
  • https://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/
like image 199
David Pine Avatar answered Oct 10 '22 01:10

David Pine