c# – 针对.net核心RC2和.net4.6.1的错误

我有以下project.json:

{
"version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027",
    "Dapper": "1.50.0-rc2b",
    "Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-final",
    "System.Dynamic.Runtime": "4.0.11-rc2-24027",
    "Microsoft.CSharp": "4.0.1-rc2-24027"
  },

  "frameworks": {
    "netstandard1.5": {
      "imports": "dnxcore50"
    },
    "net461": {}
  }
}

现在,我收到了以下警告,我宁愿没有

Dependency specified was System.Dynamic.Runtime >= 4.0.11-rc2-24027 but ended up with System.Dynamic.Runtime 4.0.10.0.

Dependency specified was Microsoft.CSharp >= 4.0.1-rc2-24027 but ended up with Microsoft.CSharp 4.0.0.0.

从框架中删除net461解决了我的问题 – 但不是首选.

但是,现在我可以猜到为什么我会得到它们,这与那些不支持net461的库有关 – 尽管对我来说这似乎有点奇怪.

我尝试使用旧版本 – 但后来我得到一个警告,Dapper期望更新版本的那些 – 任何想法?

出于某种原因,将依赖关系移动到每个框架(相同的版本)也解决了这个问题

最佳答案 应在特定于框架的元素中指定特定于框架的依赖项.像这样:

{
  "version": "1.0.0-*",

  "dependencies": {
    "Dapper": "1.50.0-rc2b",
    "Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-final",
    "System.Dynamic.Runtime": "4.0.11-rc2-24027"
  },

  "frameworks": {
    "netstandard1.5": {
      "dependencies": {
        "NETStandard.Library": "1.5.0-rc2-24027"
      },
      "imports": "dnxcore50"
    },
    "net461": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-rc2-24027"
      }
    }
  }
}
点赞