Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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)

Build error is: ResolveAssemblyReference] C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635, 5): warning MSB3268: The primary reference "Google.Apis.Auth.PlatformServices, Version=1.9.0.26016, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.22.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 "Google.Apis.Auth.PlatformServices, Version=1.9.0.26016, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Net.Http, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

Followed by: [07:58:29]W: [MSBuild output] C:\BuildAgent\work\dda43f1992063b18\Integrations\CalendarSync\Devices\Google Calendar\GoogleCalendarDevice.vb(788,78): error BC30009: Reference required to assembly 'Google.Apis, Version=1.9.0.23042, Culture=neutral, PublicKeyToken=null' containing the implemented interface 'Google.Apis.Requests.IDirectResponseSchema'. Add one to your project. [C:\BuildAgent\work\dda43f1992063b18\Integrations\CalendarSync\Severa.Integrations.CalendarSync.vbproj]

like image 915
J.Hook Avatar asked Nov 10 '22 21:11

J.Hook


1 Answers

We now have non optimal solution to the problem. MsBuild finds wrong version from one of these locations:

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..

Unfortunately our TC agents are in shared environment so we can't replace this files in all these locations.

Any ideas?

like image 119
J.Hook Avatar answered Nov 15 '22 11:11

J.Hook