2

我正在尝试移动当前支持多个目标的现有库:Profile259、.NET 4.5、.NET 4.0 Client Profile 和 NetCore451(Win 8.1+)。根据目标框架,我需要两组直接依赖项:Microsoft.Net.Http(PCL 和 .net 4.0)和 Json.NET(所有目标)。

我已经能够迁移到特定的平台目标,例如 .NET 4.5、.NET 4.0 CP、.NET 4.6 等。但是,我遇到了针对 PCL 的问题。

使用以下 project.json

"frameworks": {
".NETPortable,Version=v4.5,Profile=Profile259": {
  "compilationOptions": { "define": [ "Portable" ] },
  "dependencies": {
    "Newtonsoft.Json": "8.0.2",
    "Microsoft.Net.Http": "2.2.29"
  },
  "frameworkAssemblies": {
    "Microsoft.CSharp": "",
    "mscorlib": "",
    "System.Collections": "",
    "System.ComponentModel": "",
    "System.Diagnostics.Debug": "",
    "System.Dynamic.Runtime": "",
    "System.Globalization": "",
    "System.IO": "",
    "System.Linq": "",
    "System.Linq.Expressions": "",
    "System.Linq.Queryable": "",
    "System.Net": "",
    "System.Net.Primitives": "",
    "System.Net.Requests": "",
    "System.ObjectModel": "",
    "System.Reflection": "",
    "System.Reflection.Extensions": "",
    "System.Runtime": "",
    "System.Runtime.Extensions": "",
    "System.Text.Encoding": "",
    "System.Text.RegularExpressions": "",
    "System.Threading": "",
    "System.Threading.Tasks": ""
  }
},
"netcore451": {
  "dependencies": {
    "Newtonsoft.Json": "8.0.2"
  },
  "frameworkAssemblies": {
    "Microsoft.CSharp": "4.0.0",
    "mscorlib": "4.0.0",
    "System.Collections": "4.0.0",
    "System.ComponentModel": "4.0.0",
    "System.Diagnostics.Debug": "4.0.0",
    "System.Dynamic.Runtime": "4.0.0",
    "System.Globalization": "4.0.0",
    "System.IO": "4.0.0",
    "System.Linq": "4.0.0",
    "System.Linq.Expressions": "4.0.0",
    "System.Linq.Queryable": "4.0.0",
    "System.Net": "4.0.0",
    "System.Net.Http": "4.0.0",
    "System.Net.Primitives": "4.0.0",
    "System.Net.Requests": "4.0.0",
    "System.ObjectModel": "4.0.0",
    "System.Reflection": "4.0.0",
    "System.Reflection.Extensions": "4.0.0",
    "System.Runtime": "4.0.10",
    "System.Runtime.Extensions": "4.0.0",
    "System.Text.Encoding": "4.0.0",
    "System.Text.RegularExpressions": "4.0.0",
    "System.Threading": "4.0.0",
    "System.Threading.Tasks": "4.0.0"
  },
  "compilationOptions": {
    "define": [ "Async", "NETFX_CORE" ]
  }
}}

我最终会遇到有趣的错误,例如:

.NETPortable,Version=v4.5,Profile=Profile259 error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

.NETCore,Version=v4.5.1 error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

我能够从 Profile 259 切换到 Profile111 并删除对解决 PCL 问题的Microsoft.Net.Http的依赖。

对于netcore451,如果我删除对Json.NET的引用,系统引用问题得到解决,但库将不再编译。

长话短说,关于尝试什么的任何指导?或者我是否受制于我所依赖的库来进行一些更改?

4

0 回答 0