我的自定义类库(针对.NET 4.5.1)引用了Newtonsoft.Json 8.0.2(迄今为止的最新版本)。我已将此类库添加为对新的ASP.NET 5 Web API项目的引用。
从错误列表输出:
错误NU1002项目MyProject中的依赖项Newtonsoft.Json 1.0.0不支持框架DNXCore,Version = v5.0。
这部分似乎有些不言自明,但是,我无法理解为什么它将我引用的版本更改为 1.0.0。
来自参考资料 - > DNX 4.5.1 - > MyClassLibrary 节点:
NU1007指定的依赖关系是Newtonsoft.Json> = 8.0.2但最终使用Newtonsoft.Json 1.0.0。
我已尝试多次删除/重新添加引用,但都无济于事。我注意到有几个ASP.NET库使用Newtonsoft.Json 6.0.6 - 我不确定这是否与它有任何关系。
如果我导航到 wrap文件夹 - > Newtonsoft.Json - > json文件,并用" Newtonsoft.Json 8.0.2 - *&#替换" Newtonsoft.Json 1.0.0 - *" 34; ,它修复了DNX 4.5.1节点的引用。
但是,之后的错误仍然显示我的类库中引用的Newtonsoft.Json 8.0.2不支持DNXCore 50。
我不知道该怎么做。任何帮助将不胜感激。
答案 0 :(得分:0)
Answer to my issue: Thanks to Oleg's response I was able to make it work -- however there were two hurdles. One was the "wrap" folder that was created for Newtonsoft.Json. In the root of my solution was a "wrap" folder that contained a folder called Newtonsoft.Json. Apparently(?) that folder shouldn't have been created (how it was created I have no idea). Once removing that, I was able to add a reference to my custom class library without any errors referencing Newtonsoft.Json.
However when I began trying to use my custom assembly as in code, I would get an error about DNX50 not being supported -- which sort've makes sense because my custom referenced assembly was a .NET 4.5.1 class library.
This GitHub link has many people experiencing a similar issue
However, I managed to get everything to build and errors to go away by removing targeting for DNXCore50. This worked for me because I was just wanting to share some POCO data models between a Web API and WPF project. I'm not interested in targeting DNXCore at the moment.
I'm looking forward to the future of ASP.NET, but the newness is a bit challenging, at least for me.