Martea
Martea

Reputation: 477

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

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.

and can you make nuget just install the references with out the package dir and 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.

Upvotes: 3

Views: 2009

Answers (2)

Xiaodong Tan
Xiaodong Tan

Reputation: 101

I got the exact same message in one of my projects.

In Visual Studio 2012, I included System.Net.Http from "Assemblies > Extensions". The "Targeting" statement at the top of the dialog box says ".NET Framework 4.5.1". "System.Net.Http" of version 2.0.0.0 was checked. But I was getting this error message still.

It turned out that Visual Studio was not copying this assembly to local folder. 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. If "Copy Local" is set to "False", click on the "False" and change it to "True".

This fixed the problem for me.

Upvotes: 0

Jay Walker
Jay Walker

Reputation: 4713

Short answer, no, you can't remove the packages dir and config file if you want nuget to work correctly. Nuget adds custom targets to your project file that read the packages.config and package folder and copy to your bin folder. Also, the dll refs that nuget adds to your project use a hint path that points to the packages folder. If you remove the packages folder, the reference won't resolve.

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>

Upvotes: 1

Related Questions