.NET 4.0 ASP.Net 解决方案 + Google-api-dotnet-client 中使用 TeamCit



我们已从 TFS 2010 迁移到 TeamCity,但在构建解决方案文件时遇到问题。

我们正在使用 .NET 4.0。众所周知,Google库在尝试构建.NET 4.0 + system.net.http时会导致问题。我们设法让此设置在TFS(它使用MSBuild 4.0(上工作而没有错误。

App.config 应具有正确的程序集绑定:

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

我们已经尝试过:- 使用不同的运行器类型:Visual Studio,MSbuild- 直接引用所有Dll(google+system.net.http+etc(- 在这些DLL上使用直接Nuget包还原(它可以恢复一切正常(

构建错误为:ResolveAssemblyReference] C:\Program Files (x86(\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635, 5(: 警告 MSB3268:无法解析主要引用"Google.Apis.Auth.PlatformServices, Version=1.9.0.26016, Culture=neutral, processorArchitecture=MSIL",因为它间接依赖于框架程序集"System.Net.Http, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",该程序集无法在当前目标中解析框架。".NETFramework,版本=v4.0"。若要解决此问题,请删除引用"Google.Apis.Auth.PlatformServices, Version=1.9.0.26016, Culture=neutral, processorArchitecture=MSIL",或者将应用程序重定向到包含"System.Net.Http, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"的框架版本。

其次:[07:58:29]W: [MSBuild output] C:\BuildAgent\work\dda43f1992063b18\Integrations\CalendarSync\Devices\Google Calendar\GoogleCalendarDevice.vb(788,78(:错误 BC30009:程序集"Google.Apis, Version=1.9.0.23042, Culture=neutral, PublicKeyToken=null"需要引用,其中包含实现的接口"Google.Apis.Requests.IDirectResponseSchema"。向项目添加一个。[C:\BuildAgent\work\dda43f1992063b18\Integrations\CalendarSync\Severa.Integrations.CalendarSync.vbproj]

我们现在有非最佳解决方案。MsBuild 从以下位置之一找到错误的版本:

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.0
C:Program Files (x86)Microsoft ASP.NETASP.NET MVC 4PackagesMicrosoft.Net.Http.2.0.20710.0libnet40
C:Program Files (x86)Microsoft Web ToolsPackagesMicrosoft.Net.Http.2.0.20710.0libnet40

这是错误的,因为这些位置中的版本是:1.0.0.0。如果我们用 2.2.28 版本替换所有这些地方,它可以工作。我们尝试了以下方法:

  • Compliation.config add assembly
  • Web.config bindingredirect
  • sln 文件提示正确的包。.

不幸的是,我们的 TC 代理位于共享环境中,因此我们无法在所有这些位置替换此文件。

有什么想法吗?

最新更新