Build errors in .NET 4.0 ASP.Net solution + google-api-dotnet-client using TeamCity build server

We have migrated from TFS 2010 to TeamCity and we have issues in building our solution file.
We are using .NET 4.0. Google library which is notoriously causing issues with .NET 4.0 + system.net.http when trying to build it. We managed to get this setup working on TFS(it uses MSBuild 4.0) without errors.
App.config should have correct assemblybindings:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.28.0" newVersion="2.2.28.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.28.0" newVersion="2.2.28.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>




We have already tried:
- Use different runner types: Visual studio, MSbuild
- Referenced all Dlls directly(google+system.net.http+etc.)
- Use straight Nuget Package restore on these DLLs(it restores everything ok)
- Tried to build solution straight with MSbuild 12.0 and build succeeds


Build error are:
[11:20:44]W:  [MSBuild output]          ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'System.Net.Http, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) [C:\BuildAgent\work\186a5d9107d35c39\Website.metaproj]


BR
Joona

6 comments
Comment actions Permalink

Hi Joona,

Please try to run the same build via command line (not using TeamCity) using msbuild.exe on the same agent in the same working directory. Does the build run successfully? For more details please see the related doc section.

0
Comment actions Permalink

Hi,
Unfortunately we have limited access to the build server. We have found what is causing this issue.
We are using system.net.http library which has to be version 2.2.22 >. We are referencing this library directly(have tried nuget ref also).
It compiles in Visual Studio and runs but msbuild does take the dll from one of these places:
- C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
- C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.Net.Http.2.0.20710.0\lib\net40
- C:\Program Files (x86)\Microsoft Web Tools\Packages\Microsoft.Net.Http.2.0.20710.0\lib\net40

This is wrong since the version in these locations is: 1.0.0.0.
If we replace all these places with 2.2.28 version it works..
We have tried following:
- Compliation.config add assembly
- Web.config bindingredirect
- Sln file hints to right packages..

Any ideas?

0
Comment actions Permalink

Hi,

The file references are resolved in the following order. So for example you can use %(HintPath). It seems that the issue is not related to TeamCity.

0
Comment actions Permalink

Hi,
We are using hintpath like:

<Reference Include="System.Net.Http, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">

      <HintPath>..\..\packages\Microsoft.Net.Http.2.2.28\lib\net40\System.Net.Http.dll</HintPath>

      <SpecificVersion>False</SpecificVersion>

    </Reference>
Also we have added direct reference to the dll.
Since that library is signed it seems that order which was described in the link is not honored and system folders are considered first.

0
Comment actions Permalink

Hi,

Where is System.Net.Http.dll located on TeamCity agent machine? Is the relative path HintPath correctly resolved on build agent?

0
Comment actions Permalink

Hi,
Apologies for not replying in time. We never got this to work in TeamCity.
We have since upgraded to .NET 4.5 so these issues were fixed.
Thank you for the assistance!


BR
Joona

0

Please sign in to leave a comment.