DotNet Core RC2 Project and Net461 dependency reso

2019-06-09 03:05发布

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条回答
小情绪 Triste *
2楼-- · 2019-06-09 03:26

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": {
    }
  }
}
查看更多
登录 后发表回答