cannot add reference to .net core Class library asp.net core rc2

天涯浪子 提交于 2019-12-05 20:56:13

问题


I am a newbie in the asp.net net core world and I am struggling to adding a simple ref . I get an error

Steps

1) Created an "Asp.net Core Web Application(Net Framework) RC2"

2) Added a Class Library (.Net core) called "ClassLibrary1")

3)Within the web app.Project.json i added a reference to the classlibrary1 like this

"dependencies": { "ClassLibrary1": "1.0.0-*", etc...

4) Get error

Severity Code Description Project File Line Suppression State Error

NU1001 The dependency ClassLibrary1 could not be resolved.

I understand why microsoft is doing this as they want to be lean and modular,however there should be an option that would add the reference for you like in the classic library.It's a step back in my view.

Is this a bug or its me?

thanks for any reply


回答1:


Change your project.json in your class library to .netstandard1.4 (or lower).

Your web application is stating .NET Framework 4.6.1, but netstandard 1.5 can only target 4.6.2+ (related to .NET Framework that is).

https://github.com/dotnet/standard/blob/master/docs/versions.md

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027"
  },

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



回答2:


I ran into the same Problem. I had to manually run "Restore Packages" and the error was gone!



来源:https://stackoverflow.com/questions/37309368/cannot-add-reference-to-net-core-class-library-asp-net-core-rc2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!