在旧版.NET平台上使用.NET Core包
我正在使用VS中的一个新的“类库(包)”模板创建一个NuGet包。 我想知道,有什么方法可以使用不使用.NET Core的PCL的软件包吗?
例如,我有一个包Enu
,带有以下project.json
:
{ "title": "Enu", // project details... "dependencies": { "System.Runtime": "4.0.0" }, "frameworks": { "dotnet": { } } }
然后我有一个针对.NET 4.5,Windows 8和Windows 8.1的传统PCL。 当我尝试通过Install-Package Enu
,出现以下错误:
PM> Install-Package Enu # blah blah blah Install-Package : Could not install package 'Enu 4.0.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.
我该怎么做才能解决这个问题?
注意:奇怪的是,它适用于控制台应用程序。
是的,这是可能的。 这是一个很好的参考图(摘自这里 ):
tl; dr要将所有内容添加到project.json
:
"frameworks": { "dotnet": { }, // .NET 4.6 and DNX "net45": { }, // .NET Framework 4.5 "netcore45": { } // WinRT and Silverlight }