Jenkins无法通过缺少对程序集netstandard的引用来构建Xamarin iOS项目

时间:2018-09-20 19:04:52

标签: c# ios xamarin jenkins msbuild

我正在尝试使用Jenkins为Xamarin iOS项目构建CI管道,但由于MSBuild找不到对.NET Standard库的引用,我遇到了错误:

IDebugSettingService.cs(8,22): error CS0012: The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
ViewModels/IPresentationTabViewModel.cs(17,15): error CS0012: The type 'MulticastDelegate' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
ViewModels/ICredentials.cs(17,10): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

我可以在Mac构建计算机上的帐户上成功构建项目,但是Jenkins服务帐户始终在此处失败。我曾尝试清除并还原所有NuGet程序包,但MSBuild日志并没有太大帮助,尽管与Jenkins一起运行时,MSBuild加载的程序集似乎比我自己运行时要少得多。

这是我的项目设置的问题,还是Jenkins的问题?

2 个答案:

答案 0 :(得分:1)

事实证明,Jenkins帐户上的PATH环境变量缺少/usr/local/share/dotnet路径,因此无法访问NuGetFallbackFolder(位于NETStandard.Library引用所在的位置)。

/usr/local/share/dotnet添加到PATH修复了该构建。

答案 1 :(得分:1)

添加$ Path就像我添加的

Path=/Library/Frameworks/Mono.framework/Versions/Current/Commands:$Path:/usr/local/share/dotnet

enter image description here