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

2019-02-25 05:58发布

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条回答
仙女界的扛把子
2楼-- · 2019-02-25 06:57

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

查看更多
登录 后发表回答