在.NET 4.0项目中安装Newtonsoft.Json NuGet包失败

时间:2017-07-18 08:51:12

标签: json.net dependencies nuget

为什么我不能考虑其依赖关系在.NET 4.0项目中安装Newtonsoft.Json?

我有一个.NET类库项目,目标是.NET 4.0,它引用了Newtonsoft.Json 4.5.6 NuGet包。我想将Newtonsoft.Json升级到最新版本(v10.0.3)。此操作失败,并在程序包管理器控制台上打印出以下消息:

  

无法安装软件包' System.Net.Http 4.0.0'。您正在尝试将此软件包安装到以“.NETFramework,Version = v4.0'”为目标的项目中,但该软件包不包含任何与该框架兼容的程序集引用或内容文件。有关更多信息,请与软件包作者联系。

安装时的依赖行为是:"最低"。

查看Newtonsoft.Json NuGet包的依赖关系,显示:

  

.NETFramework,版本= V4.0   无依赖

我误解了什么吗?我希望它可以安装在.NET 4.0项目中。

完整安装日志是:

Attempting to gather dependency information for package 'Newtonsoft.Json.10.0.3' with respect to project 'XYZ', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'Newtonsoft.Json.10.0.3' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Newtonsoft.Json.10.0.3'
Resolved actions to install package 'Newtonsoft.Json.10.0.3'
Removed package 'Newtonsoft.Json.4.5.6' from 'packages.config'
Successfully uninstalled 'Newtonsoft.Json.4.5.6' from XYZ Removed package 'System.Net.Http.2.0.20710' from 'packages.config'
Successfully uninstalled 'System.Net.Http.2.0.20710' from XYZ
Adding package 'Newtonsoft.Json.10.0.3' to folder 'c:\MAIN\packages'
Added package 'Newtonsoft.Json.10.0.3' to folder 'c:\MAIN\packages'
Added package 'Newtonsoft.Json.10.0.3' to 'packages.config'
Executing script file 'c:\MAIN\packages\Newtonsoft.Json.10.0.3\tools\install.ps1'...
Successfully installed 'Newtonsoft.Json 10.0.3' to XYZ Install failed.
Rolling back...
Package 'System.Net.Http.4.0.0' does not exist in project 'XYZ'
Removed package 'Newtonsoft.Json.10.0.3' from 'packages.config'
Adding package 'System.Net.Http.2.0.20710', which only has dependencies, to project 'XYZ'.
Package 'System.Net.Http.2.0.20710' already exists in folder 'c:\MAIN\packages'
Added package 'System.Net.Http.2.0.20710' to 'packages.config'
Package 'Newtonsoft.Json.4.5.6' already exists in folder 'c:\MAIN\packages'
Added package 'Newtonsoft.Json.4.5.6' to 'packages.config'
Removing package 'Newtonsoft.Json.10.0.3' from folder 'c:\MAIN\packages'
Removed package 'Newtonsoft.Json.10.0.3' from folder 'c:\MAIN\packages'
Could not install package 'System.Net.Http 4.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
========== Finished ==========

将Newtonsoft.Json安装到.NET 4.0项目中的唯一方法是使用依赖行为"忽略依赖关系"。

0 个答案:

没有答案