简体   繁体   English

参考错误TFS和Nuget

[英]Reference Error TFS & Nuget

The type 'System.Net.Http.HttpMessageHandler' is defined in an 
assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 

\Global.cs  

The package that were trying to get to work is the AspNetWebApi from nuget from the Nightly Builds from aspnetwebstack 试图开始工作的软件包是来自aspnetwebstack的Nightly Builds中的nuget的AspNetWebApi

Got some trouble with TFS Reference, when I make nuget install-package to the current project and all DLL's are local places since its a website project, I get this weird message, if I rebuild the whole solution it will run smoothly, but when I change the slightest thing in a CS file that needs to compile the error repeats it self. 在使用TFS Reference时出现了一些问题,当我将nuget install-package安装到当前项目中时,所有DLL都是本地的,因为它是一个网站项目,我得到这个奇怪的消息,如果我重建整个解决方案它会顺利运行,但是当我更改CS文件中需要编译错误的最轻微的事情重复它自己。

and can you make nuget just install the references with out the package dir and packages.config? 你可以让nuget只是在包dir和packages.config中安装引用吗?

Wonder if anyone has a solution to this problem? 不知道有没有人能解决这个问题?

Or if you have any good articles about references nuget & tfs practices you could recommend. 或者,如果您有关于参考nuget和tfs实践的任何好文章,您可以推荐。

Short answer, no, you can't remove the packages dir and config file if you want nuget to work correctly. 简短的回答,不,如果你想让nuget正常工作,你不能删除包dir和配置文件。 Nuget adds custom targets to your project file that read the packages.config and package folder and copy to your bin folder. Nuget将自定义目标添加到项目文件中,该文件读取packages.config和package文件夹并复制到bin文件夹。 Also, the dll refs that nuget adds to your project use a hint path that points to the packages folder. 此外,nuget添加到项目中的dll引用使用指向packages文件夹的提示路径。 If you remove the packages folder, the reference won't resolve. 如果删除packages文件夹,则引用将无法解析。

For example: 例如:

<Reference Include="Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\packages\Microsoft.SqlServer.2008R2.Smo.1.0.0\lib\net40\Microsoft.SqlServer.Management.Sdk.Sfc.dll</HintPath>
</Reference>

I got the exact same message in one of my projects. 我在我的一个项目中得到了完全相同的消息。

In Visual Studio 2012, I included System.Net.Http from "Assemblies > Extensions". 在Visual Studio 2012中,我从“Assemblies> Extensions”中包含了System.Net.Http。 The "Targeting" statement at the top of the dialog box says ".NET Framework 4.5.1". 对话框顶部的“Targeting”语句显示“.NET Framework 4.5.1”。 "System.Net.Http" of version 2.0.0.0 was checked. 检查版本2.0.0.0的“System.Net.Http”。 But I was getting this error message still. 但我仍然收到此错误消息。

It turned out that Visual Studio was not copying this assembly to local folder. 原来,Visual Studio没有将此程序集复制到本地文件夹。 It is probably grabbing one of some other version on my machine somewhere. 它可能在我的机器上的某个地方抓住了其他一个版本。

Here is how you can change the "Copy Local": with the reference "System.Net.Http" highlighted in the Solution Explorer, press the "F4" key to go to its property window. 以下是如何更改“复制本地”:在解决方案资源管理器中突出显示引用“System.Net.Http”,按“F4”键转到其属性窗口。 If "Copy Local" is set to "False", click on the "False" and change it to "True". 如果“Copy Local”设置为“False”,请单击“False”并将其更改为“True”。

This fixed the problem for me. 这解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM