System.Net.Http could not be resolved in the currently targeted framework .NET 4.0

拜拜、爱过 提交于 2019-11-28 18:53:20

So even though I was copying System.Net.Http .NET 4.0 via the Nuget package that is added when installed the DotNetOpenAuth packages, MsBuild on my build server was checking the DotNetOpenAuth.Core dependency and checking against .NET assemblies installed on the machine not what was being copied to the Bin. In my case:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

And there was no System.Net.Http assembly in my

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

directory so I believe MsBuild attempted to look in the newly installed .NET 4.5 assemblies, on my machine..\Assemblies\Microsoft\Framework.NETFramework\v4.5 where there is a System.Net.Http.dll and that is why, instead of getting an outright error that System.Net.Http.dll for .NET 4.0 targets does not exist, I got a warning about DotNetOpenAuth.Core.dll's dependency on System.Net.Http, which can be found but is not for the 4.0 framework as the project was targeting.

I simply copied System.Net.Http .NET 4.0 DLL from the package to

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

on my build server and MsBuild was able to compare to the correct version System.Net.Htpp for 4.0 .NET framework dependency check.

If this fails, you may also need to apply the .Net v4.5.1 dev pack as this supports multiple targeting. I had 4.5.1 installed and the assemblies copied and still had this error. Installing the dev pack from http://www.microsoft.com/en-us/download/details.aspx?id=40772 fixed this issue and now builds under server 2012 r2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!