How to use PCL in ASP.NET Core 1.0 RC2 project

时光毁灭记忆、已成空白 提交于 2019-12-20 01:41:47

问题


I want to use a simple (POCO only without other dependencies) PCL with targets

  • Xamarin.Android
  • Universal Windows 10
  • ASP.NET Core 1.0

in an ASP.NET Core 1.0 RC2 project (all in the same solution). I have added this import to my project.json:

"frameworks": {
  "netcoreapp1.0": {
    "imports": [
      "dotnet5.6",
      "dnxcore50",
      "portable-net451+win8"
    ],
    "dependencies": {
      "PCL.Library": {
        "target": "project"
      }
    }
  }
}

I don’t get any errors (compilation or otherwise) and the PCL.Library project shows up in the references (without warning signs or anything). But I can’t use it in my ASP.NET Core 1.0 RC2 project because the using statements don’t resolve as if the PCL was not referenced at all.

How do I have to configure my PCL project and my ASP.NET Core project so that I can use the PCL?

Update: it does not work with the RTM version either. No reponse from the dev team on the GitHub issue leaves me thinking there is a fundamental issue making this impossible.


回答1:


I believe this is related to: https://github.com/aspnet/Home/issues/1356

It might be best to follow up on this issue tracker and ask for the current status although it says it will be supported in RC2.

This is part of the whole .NET platform standardization via the netstandard(https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md)

You can read more about this here:

http://damien.dennehy.me/blog/2016/01/15/class-library-packages-future-class-libraries/

Note: There's a doc I found today regarding targeting a PCL:

http://dotnet.github.io/docs/core-concepts/libraries/libraries-with-cli.html#how-to-target-a-portable-class-library-pcl



来源:https://stackoverflow.com/questions/37274240/how-to-use-pcl-in-asp-net-core-1-0-rc2-project

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