Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity - MSBuild unable to locate NuGet references

Attempting to build a C# project which has numerous references to assemblies in NuGet packages fails in TeamCity but works fine in Visual Studio.

Found in the log;

For SearchPath "{HintPathFromItem}".

[13:48:15][ResolveAssemblyReference]         
Considered "..\packages\AspNetMvc.4.0.20126.16343\lib\net40\System.Web.Mvc.dll", but it didn't exist.

The reference in the project file is;

<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\packages\AspNetMvc.4.0.20126.16343\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>

Any ideas? It seems like it's not starting from the correct directory so can't resolve "../packages" which exists one level above the .csproj file.

like image 618
SeeNoWeevil Avatar asked Mar 16 '12 09:03

SeeNoWeevil


1 Answers

I know this has been answered, but maybe someone else has had the same problem I did.

My hint paths in my project file were incorrectly pointing to packages and changing it to ..packages fixed it for me.

So changing it from this:

<Reference Include="Newtonsoft.Json">
  <HintPath>packages\Newtonsoft.Json.5.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>

To this:

<Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.5.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>

Fixed it.

like image 67
Tjaart Avatar answered Oct 21 '22 14:10

Tjaart