[英].NETStandard Library nuget package - cannot install on standard project
I have .NET Core project with the following project.json
: 我有带有以下
project.json
.NET Core项目:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
},
"scripts": {
"postcompile": [
"dotnet pack --no-build --configuration %compile:Configuration%"
]
}
}
I have created nuget package (see postcompile
above) and published in nuget. 我创建NuGet包(见
postcompile
以上)和出版的NuGet。
Then I've created standard 4.6.2 library, but cannot install package - there is error that package doesn't contain valid assemblies for target .NET Framework 4.6.2. 然后,我创建了标准的4.6.2库,但是无法安装软件包-软件包不包含目标.NET Framework 4.6.2的有效程序集的错误。
How should I prepare nuget package to make it available in standard library? 我应该如何准备nuget软件包以使其在标准库中可用? I thiough that target NETStandard is valid for both - core and standard projects.
尽管目标NETStandard对核心项目和标准项目均有效。
If you check the compatibility matrix for .Net Standard it looks like .Net 4.6.2 only supports NetStandard 1.5. 如果检查.Net Standard的兼容性矩阵,则看起来.Net 4.6.2仅支持NetStandard 1.5。 Under frameworks you are targeting 1.6 that is marked for vNext.
在框架下,您将目标标记为vNext的1.6。
See here for the compatibility matrix to know what version you should target 有关兼容性矩阵,请参见此处,以了解您应该定位的版本
So in other words if you change your config to the following you should be able to reference the library freely: 因此,换句话说,如果将配置更改为以下内容,则应该可以自由引用该库:
"frameworks":
{
"netstandard1.5": {}
}
You don't need to add another framework type like suggested in another answer since 4.6.2 should be able to reference a 1.5 Standard. 您无需添加其他答案中建议的其他框架类型,因为4.6.2应该能够引用1.5标准。
you should be able to add support for .Net Framework 4.6.2 with adding "net462" to your project.json: 您应该能够通过在project.json中添加“ net462”来添加对.Net Framework 4.6.2的支持:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
},
"net462": {
"dependencies" : {
"System.Runtime": "4.0.20.0" // you may have to add this
// add here your dependencies
}
}
},
"scripts": {
"postcompile": [
"dotnet pack --no-build --configuration %compile:Configuration%"
]
}
}
see also my project.json on github with a few supported frameworks 另请参阅我在github上的project.json和一些受支持的框架
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.