0

I was just looking at the project.json file in one of my ASP.NET Core projects and noticed there are two different areas to list dependencies.

One inside the frameworks node and the other is a dependencies node. Why/when would/should you place the dependencies in one location over the other?

{
    "version": "1.0.0-*",
    "description": "My Class Library",
    "authors": [ "" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",
    "frameworks": {
        "dotnet5.4": {
            "dependencies": {
                "Microsoft.CSharp": "4.0.1-beta-23516",
                "System.Collections": "4.0.11-beta-23516",
                "System.Linq": "4.0.1-beta-23516",
                "System.Runtime": "4.0.21-beta-23516",
                "System.Threading": "4.0.11-beta-23516"
            }
        }
    },
    "dependencies": {
        "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final"
    }
}

1 Answer 1

0

The reason is very easy. You can have different dependencies for different frameworks.

In some cases the specified dependence exist in different versions for different frameworks.

In another case the specified dependency like System.Runtime needed be not included as all. The problem is here the DLL is separate module in .NET Core (see here), but the dnx46 or dnx451 contains the implemented methods inside of .Net framework. One don't need to include no external (additional) dll. Thus you need don't include System.Runtime package in the the dnx451 part of the dependencies or as the common dependency. Thus System.Runtime is framework-specific dependencies.

In some seldom cases you can include the dependency in the form "dnx451": "frameworkAssemblies": { "System.Runtime": "" }} to skip including of System.Runtime if it was erroneously required (see the question). Typically one uses frameworkAssemblies to reference to assemblies from Global Assembly Cache (GAC) without redistributing it (see the documentation).

Sign up to request clarification or add additional context in comments.

7 Comments

I understand that if your targeting multiple frameworks you can specify different versions for each framework. But what about the pure dependencies node that is not tied to any framework?
@MatthewVerstraete: It's common dependency used for every targeting framework. For example EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final" is not included as the part of some framework and the package supports dotnet5.4, dnx451 and dnxcore50. Thus you can include it as common dependency.
I see, can you amend your answer for that so it address both parts of the question?
@MatthewVerstraete: Sorry, but I don't understand what you mean. What "both parts of the question" you mean? project.json have two places for including dependencies: "dependencies" includes common dependencies over all "frameworks" which you use and "frameworks"."frameworkName"."dependencies" includes dependencies which are used only during building the target for the specified framework. I prescribed examples when such framework-specific dependencies could be required.
You answer explains why there is a dependencies section for the framework node but does not explain the usage of the dependences node by it's self.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.