System.Net.Http不能在当前的目标框架.NET 4.0来解决 [英] System.Net.Http could not be resolved in the currently targeted framework .NET 4.0

查看:1454
本文介绍了System.Net.Http不能在当前的目标框架.NET 4.0来解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Visual Studio移动解决方案,2010年至2012年打造的是罚款和一切都运行完美本地主机后,得到了一个讨厌的错误。我有要求.NET 4.5一新MVC4项目,所以我安装了构建服务器上的4.5框架。构建是好的,但被的MSBuild未能从包装位置复制DotNetOpenAuth.Core.dll到Bin目录。这个问题是因为,虽然特定项目的目标4.0框架,我相信是的MSBuild检查对.NET 4.5框架System.Net.Http组件的依赖作为其CoreBuild的一部分。

Got a nasty error after moving a solution from Visual Studio 2010 to 2012. Build is fine and everything works perfect localhost. I have one new MVC4 project that requires .NET 4.5 so I installed the 4.5 framework on the build server. The build is good but MSBuild is failing to copy DotNetOpenAuth.Core.dll from its package location to the Bin dir. The issue is because, though the particular project targets the 4.0 framework, I believe MSBuild is checking the dependency against .NET 4.5 framework System.Net.Http assembly as part of its CoreBuild.

警告code =MSB3268的主要参考\\包\\ DotNetOpenAuth.Core.4.3.0.13117 \\ LIB \\ net40满\\ DotNetOpenAuth.Core.dll无法得到解决,因为它的一个间接依赖框架组装System.Net.Http,版本= 2.0.0.0,文化=中性公钥= b03f5f7f11d50a3a,它无法在当前的目标框架内解决。.NETFramework,版本= 4.0版。要解决此问题,要么删除参考\"c:\\cc\\kazork\\$c$c\\trunk\\src\\packages\\DotNetOpenAuth.Core.4.3.0.13117\\lib\
et40-full\\DotNetOpenAuth.Core.dll\"或重新定位你的应用程序,其中包含一个框架版System.Net.Http,版本= 2.0.0.0,文化=中性公钥= b03f5f7f11d50a3a

warning code="MSB3268" The primary reference \packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net40-full\DotNetOpenAuth.Core.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "c:\cc\kazork\code\trunk\src\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net40-full\DotNetOpenAuth.Core.dll" or retarget your application to a framework version which contains "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

下面是我的包的配置:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="ChardinJs" version="1.0.3" targetFramework="net40" />
  <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
  <package id="DotNetOpenAuth.AspNet" version="4.3.0.13117" targetFramework="net40" />
  <package id="DotNetOpenAuth.Core" version="4.3.0.13117" targetFramework="net40" />
  <package id="DotNetOpenAuth.OAuth.Consumer" version="4.3.0.13117" targetFramework="net40" />
  <package id="DotNetOpenAuth.OAuth.Core" version="4.3.0.13117" targetFramework="net40" />
  <package id="DotNetOpenAuth.OpenId.Core" version="4.3.0.13117" targetFramework="net40" />
  <package id="DotNetOpenAuth.OpenId.RelyingParty" version="4.3.0.13117" targetFramework="net40" />
  <package id="EntityFramework" version="5.0.0" targetFramework="net40" />
  <package id="flexigrid" version="1.1.0" targetFramework="net40" />
  <package id="jQuery" version="1.9.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.FriendlyUrls.Core" version="1.0.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.Membership.OpenAuth" version="1.0.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.SignalR.Core" version="1.1.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.SignalR.JS" version="1.1.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.SignalR.Owin" version="1.1.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.SignalR.SystemWeb" version="1.1.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net40" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="1.0.1" targetFramework="net40" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
  <package id="Newtonsoft.Json" version="5.0.5" targetFramework="net40" />
  <package id="Owin" version="1.0" targetFramework="net40" />
  <package id="PayPalCoreSDK" version="1.1.1" targetFramework="net40" />
  <package id="PayPalMerchantSDK" version="2.3.98" targetFramework="net40" />
  <package id="Select2.js" version="3.3.2" targetFramework="net40" />
  <package id="toastr" version="1.2.2" targetFramework="net40" />
  <package id="Twitter.Bootstrap" version="2.3.2" targetFramework="net40" />
  <package id="WebGrease" version="1.3.0" targetFramework="net40" />
</packages>

我有System.Net.Http引用,它被复制到bin。有问题的项目瞄准的是4.0框架。我的版本System.Net.Http是针对4.0框架。

I have System.Net.Http referenced and it is copied to the bin. The project in question is targeting the 4.0 framework. My version System.Net.Http is for the 4.0 framework.

推荐答案

所以,即使我通过安装在DotNetOpenAuth包时所添加的NuGet包复制System.Net.Http .NET 4.0,我的MSBuild生成服务器上是检查DotNetOpenAuth.Core依赖和检查,对没有什么被复制到Bin机器上安装的.NET程序集。在我的情况:

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

和没有System.Net.Http装配在我的

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

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

目录,所以我相信的MSBuild试图在新安装的.NET 4.5程序集的样子,我的机器上.. \\组件\\微软\\ Framework.NETFramework \\ V4.5那里是一个System.Net.Http.dll和正因为如此,而不是得到一个彻底的错误System.Net.Http.dll对.NET 4.0的目标是不存在的,我得到了一个警告有关DotNetOpenAuth.Core.dll对System.Net.Http的依赖,可以发现,但不是为4.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.

我只是复制System.Net.Http .NET 4.0从包装到C:\\ Program Files文件(x86)的\\参考大会\\微软\\ Framework.NETFramework \\我的构建服务器,并上的MSBuild V4.0是能够比较正确的版本System.Net.Htpp 4.0 .NET框架的相关性检查。

I simply copied System.Net.Http .NET 4.0 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.

这篇关于System.Net.Http不能在当前的目标框架.NET 4.0来解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆