c# - .NETStandard 库 nuget 包 - 无法安装在标准项目上

标签 c# nuget .net-core

我的 .NET Core 项目包含以下 project.json:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  },

  "scripts": {
    "postcompile": [
      "dotnet pack --no-build --configuration %compile:Configuration%"
    ]
  }
}

我已经创建了 nuget 包(参见上面的 postcompile)并在 nuget 中发布。

然后我创建了标准 4.6.2 库,但无法安装程序包 - 错误是程序包不包含目标 .NET Framework 4.6.2 的有效程序集。

我应该如何准备 nuget 包以使其在标准库中可用?我认为目标 NETStandard 对核心项目和标准项目都有效。

最佳答案

如果您检查 .Net Standard 的兼容性矩阵,它看起来像 .Net 4.6.2 只支持 NetStandard 1.5。在框架下,您的目标是标记为 vNext 的 1.6。

See here for the compatibility matrix to know what version you should target

换句话说,如果您将配置更改为以下内容,您应该能够自由引用该库:

"frameworks": 
{
    "netstandard1.5": {}
}

您不需要像另一个答案中建议的那样添加其他框架类型,因为 4.6.2 应该能够引用 1.5 标准。

关于c# - .NETStandard 库 nuget 包 - 无法安装在标准项目上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40042474/

相关文章:

.net-core - 'reportgenerator' 不是内部或外部命令,也不是可运行的程序或批处理文件

visual-studio - Nuget通过配置文件激活 "Include Prerelease"

.net-core - .NET Core 中的 Azure Web 作业

c# - 获取类库中的当前目录

c# - 添加 dll 引用到 asp.net mvc 应用程序,无需重新启动应用程序

c# - 发现不同版本的 "System.Runtime.CompilerServices.Unsafe"冲突无法解决

visual-studio - Nuget 在构建期间更新包,即使配置为不更新包

asp.net-mvc - HttpContext.RequestAborted 和 CancellationToken 参数有什么区别?

c# - 定义并获取 ASP.Net Core (Session) 列表

c# - 减少 Update 和 Sum Query C# Access DB 的时间?