0
votes

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?

1
I didn't understand what you are trying to achieve. In the upper code section you are targeting .NET Core and .NET Framework (But you still cannot use all of your bins\libs of .NET Framework in .NET Core, at least not yet) and in the bottom you are referencing just .NET Framework not .NET Core. Are you trying to use .NET Framework libraries instead of CoreFx? - Janshair Khan
@JanshairKhan I am trying to create a .net framework library and use it as a reference to .net core web project. - maxisam

1 Answers

4
votes

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:

"frameworks": {
  "netcoreapp1.0": {        
      "imports": [
          "dotnet5.6",
          "dnxcore50",
          "portable-net45+win8"
      ]
  }
}

And library (the version of netstandard will depend on what you want to do):

"frameworks": {
    "netstandard1.4": {
    }
}

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):

"frameworks": {
  "net461": {
    "frameworkAssemblies": {
    }
  }
}