.NET Core和.Net 4.5.2都使用的公共类库

Jon*_*Rea 13 .net portable-class-library .net-core

我对.Net Core很新,但已经建立了一个有效的Asp.Net核心WebAPI站点 - 现在我想与另一个项目共享一些代码......

  • 我安装了Update Studio的Visual Studio 2015.
  • 我从这里安装了DotNetCore.1.0.0-VS2015Tools.Preview2.exe .

我想创建一个可以被其他两个库使用的共享库(PCL) - 它只包含没有其他依赖项的基本类/接口.其中一个消费库是一个针对"netstandard1.6"的新vanilla项目,另一个是针对.Net 4.5.2的旧客户端库(如果必须,我可以将其升级到4.6.x).

我已经圆圈了,我不能让netstandard1.6库引用PCL - 我只是被告知类型丢失了:

错误CS0246:找不到类型或命名空间名称'SomeTypeHere'(您是否缺少using指令或程序集引用?)

名为"ClassLibrary1"的project.json的PCL自动生成为:

{
  "supports": {},
  "dependencies": {
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "1.6.0"
  },
  "frameworks": {
    "netstandard1.1": {}
  }
}
Run Code Online (Sandbox Code Playgroud)

我的消费库project.json是:

{
  "version": "1.0.0-*",
  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.1"
  },
  "frameworks": {
    "netstandard1.6": {
      "dependencies": {
        "ClassLibrary1": {
          "target": "project"
        }
      }
    }
  }
}  
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

编辑07/07/2016:

我已经提供了以下解决方案,它演示了我的设置:https: //github.com/JonnyWideFoot/netcore-prototype 请参阅ExperimentClient :: GetLocationAsync我想在.Net 4.5.2/4.6中使用合同库的位置.x客户端.

Jon*_*Rea 1

我发现实现这项工作的唯一方法是破解引用客户端库的 .csproj 文件: https: //github.com/JonnyWideFoot/netcore-prototype/blob/master/src/JE.API.Experiment。客户端/JE.API.Experiment.Client.csproj

<Reference Include="JE.Api.Experiment.Contract, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\JE.Api.Experiment.Contract\bin\$(Configuration)\net452\JE.Api.Experiment.Contract.dll</HintPath> </Reference>

通过将合同库中的正确输出文件夹的路径硬编码,一切都很好。

...认为这可能是视觉工作室中的一个错误。