我最近制作了自己的ubuntu / jenkins / git / sonar构建服务器,并尝试用它构建我的.net控制台应用程序。
它似乎构建完美,我使用mono:
从jenkins运行它Thermostate setting through Google Calendar API
====================
ERROR: Could not load type 'Google.Apis.Auth.OAuth2.BearerToken+AuthorizationHeaderAccessMethod' from assembly 'Google.Apis.Auth, Version=1.9.0.26011, Culture=neutral, PublicKeyToken=null'.
我启用了nuget,它告诉我
Restoring NuGet packages...
在构建期间,所以它似乎抓住了nuget包。
从终端开始以sudo身份运行所有内容让我知道:
vagrant@vagrant-ubuntu-utopic-64:/var/lib/jenkins/jobs/CalendarAPI/workspace/ConsoleApplication3$ sudo mono /var/lib/jenkins/jobs/CalendarAPI/workspace/ConsoleApplication3/bin/Debug/ConsoleApplication3.exe
Thermostate setting through Google Calendar API
====================
Could not load signature of Google.Apis.Auth.OAuth2.BearerToken+AuthorizationHeaderAccessMethod:Intercept due to: Could not load file or assembly or one of its dependencies.
Could not load signature of Google.Apis.Auth.OAuth2.IAccessMethod:Intercept due to: Could not load file or assembly or one of its dependencies.
ERROR: Could not load type 'Google.Apis.Auth.OAuth2.BearerToken+AuthorizationHeaderAccessMethod' from assembly 'Google.Apis.Auth, Version=1.9.0.26011, Culture=neutral, PublicKeyToken=null'.
我做错了什么?
答案 0 :(得分:1)
我相信这是Microsoft的.NET Framework和Mono之间的区别。
Google.Apis.Auth NuGet软件包依赖于System.Net.Http.dll,该软件包含在Microsoft.Net.Http NuGet软件包中。 Google.Apis.Auth引用旧版本的System.Net.Http 1.5.0.0,在Windows上将其重定向到System.Net.Http 4.0.0.0但在Mono上不会发生此重定向。此外,对于.NET 4.5项目,当您添加Microsoft.Net.Http NuGet包时,不会直接引用System.Net.Http.dll,但它是针对.NET 4.0项目引用的。
解决此问题的可能方法是:
绑定重定向可能是最简单的解决方案。