我试图移动当前支持多个目标的现有库: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并删除对 Microsoft.Net.Http 的依赖,从而解决了PCL问题。
对于 netcore451 ,如果删除对 Json.NET 的引用,系统引用问题将得到解决,但库将不再编译。
长话短说,关于尝试什么的任何指导?或者我是否依赖于我依赖的库进行一些更改?