【发布时间】:2015-12-26 06:33:01
【问题描述】:
我有一个针对以下平台的 PCL:
- .NET Framework 4.5
- Windows 8
- Windows Phone 8.1
我还有一个基于 .NET Core 和 project.json 的包(称为 Enu),我想在这个 PCL 中使用它。我的问题是,当我尝试将 .NET Core 包安装到我的 PCL 中时,我收到一条错误消息,指出 PCL 与该包不兼容。
PM> Install-Package Enu
# lots of output...
Install failed. Rolling back...
Package 'Enu 4.4.0' does not exist in project 'PclDummy'
Package 'Enu 4.4.0' does not exist in folder 'C:\Users\James\Documents\Visual Studio 2015\Projects\PclDummy\packages'
Install-Package : Could not install package 'Enu 4.4.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain
any assembly references or content files that are compatible with that framework. For more information, contact the package author.
在深入研究了这个问题之后,我发现 Enu 所依赖的包,特别是 System.Runtime (v4.0.0),在我的 PCL 上安装时似乎也有问题 (related post)。奇怪的是,虽然它声称与我的库不兼容,但它 supports all of the target platforms I do,所以我不明白为什么会这样。
TL;DR: NuGet 不允许在 PCL 上安装 .NET Core 包,因为它认为它们不兼容。经过调查,我发现问题的根源是包的依赖项与 PCL 不兼容,尽管 it supports all of the platforms 我的 PCL 确实如此。为什么会这样?
这是 .NET Core 包的 project.json 文件,我做错了吗?
【问题讨论】:
-
@Claies 哎呀,不小心链接到我的主分支上的
project.json。 Here 是撰写本文时的样子。 -
无论如何,我的评论有点快;我还在研究这个问题
标签: c# asp.net .net nuget asp.net-core