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

We moved from TFS 2010 to TeamCity, and we have problems creating our solution file.

We are using .NET 4.0. The Google library, as you know, causes problems with .NET 4.0 + system.net.http when trying to create it. We were able to configure this setting on TFS (it uses MSBuild 4.0) without errors.

App.config must have the correct builds:

<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 types of runners: Visual studio, MSbuild - Link to all Dlls directly (google + system.net.http +, etc.) - Use direct recovery of the Nuget package on these DLLs (it restores everything in order )

Build error: ResolveAssemblyReference] C: \ Program Files (x86) \ MSBuild \ 12.0 \ bin \ Microsoft.Common.CurrentVersion.targets (1635, 5): warning MSB3268: main link "Google.Apis.Auth.PlatformServices, version = 1.9 .0.26016, Culture = neutral, processorArchitecture = MSIL "cannot be resolved because it has an indirect dependency on the system build" System.Net.Http, Version = 2.2.22.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a ", which cannot be allowed in the current target framework. ".NETFramework, Version = v4.0". To fix this problem, delete the link "Google.Apis.Auth.PlatformServices, Version = 1.9.0.26016, Culture = neutral, processorArchitecture = MSIL" or migrate the application to the version of the framework containing "System.Net.Http, Version = 2.2.22.0 , Culture = Neutral, PublicKeyToken = b03f5f7f11d50a3a. "

The following are: [07:58:29] W: [MSBuild output] C: \ BuildAgent \ work \ dda43f1992063b18 \ Integrations \ CalendarSync \ Devices \ Google Calendar \ GoogleCalendarDevice.vb (788.78): error BC30009: Link required for Google builds. Apis, Version = 1.9.0.23042, Culture = neutral, PublicKeyToken = null ', containing the implemented interface' Google.Apis.Requests.IDirectResponseSchema '. Add it to your project. [C: \ BuildAgent \ work \ dda43f1992063b18 \ integration \ CalendarSync \ Severa.Integrations.CalendarSync.vbproj]

+5
source share
1 answer

Now we have not the optimal solution to the problem. MsBuild finds the wrong version 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 not true because the version in these places is 1.0.0.0. If we replace all these places with version 2.2.28, it will work. We tried the following:

  • Compliation.config add assembly
  • Web.config bindingredirect
  • Hints in the Sln file for the right packages.

Unfortunately, our TC agents are in a common environment, so we cannot replace these files in all these places.

Any ideas?

+1
source

Source: https://habr.com/ru/post/1209312/


All Articles