使用TeamCity构建服务器在.NET 4.0 ASP.Net解决方案+ google-api-dotnet-client中构建错误

J.H*_*ook 5 asp.net teamcity google-api-dotnet-client

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

我们使用的是.NET 4.0.谷歌图书馆在尝试构建时会出现.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>
Run Code Online (Sandbox Code Playgroud)

我们已经尝试过: - 使用不同的跑步者类型:Visual Studio,MSbuild - 直接引用所有Dlls(google + system.net.http +等) - 在这些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输出] 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 \工作\ dda43f1992063b18 \集成\ CalendarSync\Severa.Integrations.CalendarSync.vbproj]

J.H*_*ook 1

我们现在对这个问题有非最优的解决方案。MsBuild 从以下位置之一发现错误版本:

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
Run Code Online (Sandbox Code Playgroud)

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

  • Compliation.config 添加程序集
  • Web.config 绑定重定向
  • Sln 文件提示正确的包..

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

有任何想法吗?