Here is the project.json for the main dotnet core web project
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8",
"net461"
]
}
}
If I add the following net461 class library project as a reference to above one. It won't build correctly.
"frameworks": {
"net461": {
}
}
and throw error like The dependency mscorlib could not be resolved.
However, if I create a project by using the old template(no project.json), and add it as a reference to dotnet core project. It works fine.
I wonder how to fix this?
What you're doing is creating a library that will run only on .Net Framework, and then trying to use it from an application that runs on .Net Core. That won't work.
If you want to run on .Net Core, then project.json of your application should contain:
And library (the version of
netstandard
will depend on what you want to do):If you want to use dotnet CLI, but still run on .Net Framework, then have the following in both your library and application (where you include framework assemblies inside
frameworkAssemblies
):