为什么我的F#项目在本地构建但在Travis上失败?

时间:2022-08-08 15:36:51

The build for my project is failing on Travis with the following error:

我的项目的构建在Travis上失败,出现以下错误:

FSC: error FS0193: The module/namespace 'System.Net' from compilation unit 'System' did not contain the namespace, module or type 'WebClient'

FSC:错误FS0193:来自编译单元'System'的模块/名称空间'System.Net'不包含名称空间,模块或类型'WebClient'

The main project doesn't have any dependencies, and the test project doesn't depend on System.Net or WebClient, so I'm not sure how that applies here.

主项目没有任何依赖项,测试项目不依赖于System.Net或WebClient,所以我不确定这是如何应用的。

Everything works fine locally, so I'm assuming a version mismatch somewhere but haven't been able to identify what.

一切都在本地工作正常,所以我假设某个版本不匹配,但无法识别什么。

The output of my local build can be found in this text file.

可以在此文本文件中找到本地构建的输出。


Update

Following the GitHub issue created by @7sharp9 it was discovered that this is a Mono packaging bug.

在@ 7sharp9创建的GitHub问题之后,发现这是一个Mono包装错误。

The suggested workaround was to reference FSharp.Core from the NuGet package instead, which worked for me.

建议的解决方法是从NuGet包中引用FSharp.Core,这对我有用。

You may wish to only use the NuGet package when the canonical path is unavailable, as I did.

您可能希望仅在规范路径不可用时使用NuGet包,就像我一样。

1 个解决方案

#1


11  

The travis version is building with an FSharp.Core from the GAC:

travis版本使用GAC的FSharp.Core构建:

-r:/usr/lib/mono/gac/FSharp.Core/4.3.1.0__b03f5f7f11d50a3a/FSharp.Core.dll

Whereas your local build is using the FSharp.Core at:

而您的本地构建使用FSharp.Core:

-r:"/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll"

The error you are getting:

你得到的错误:

FSC: error FS0193: The module/namespace 'System.Net' from compilation unit 'System' did not contain the namespace, module or type 'WebClient'

FSC:错误FS0193:来自编译单元'System'的模块/名称空间'System.Net'不包含名称空间,模块或类型'WebClient'

Indicated a mismatched FSharp.Core where its trying to resolve System.Net references from the Fsharp.Core located in the GAC, the other references in your project are all PCL 259 which will not satisfy this reference.

指示不匹配的FSharp.Core,它试图从位于GAC的Fsharp.Core中解析System.Net引用,项目中的其他引用都是PCL 259,它们不满足此引用。

As to why, could you get travis to build using the diagnostic switch?

至于为什么,你能使用诊断开关进行travis吗?

Ok so following on, now that there is a diagnostic build linked, the problem is here:

好的,接下来,现在已经链接了诊断构建,问题在于:

HintPath /usr/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll does not exist. Reference FSharp.Core resolved to /usr/lib/mono/gac/FSharp.Core/4.4.0.0__b03f5f7f11d50a3a/FSharp.Core.dll. CopyLocal = False Reference found at search path {GAC}

HintPath /usr/lib/mono/xbuild/../参考程序集/ Microsoft / FSharp / .NETCore / 3.259.3.1 / FSharp.Core.dll不存在。参考FSharp.Core已解析为/usr/lib/mono/gac/FSharp.Core/4.4.0.0__b03f5f7f11d50a3a/FSharp.Core.dll。在搜索路径{GAC}中找到CopyLocal = False参考

The travis instance does not have:

travis实例没有:

/usr/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll

So it reverts to the gac.

所以它回归到gac。

There was a recent issue where FSharp.Core was not installed to the correct location, maybe this is a manifestation of that.

有一个最近的问题,FSharp.Core没有安装到正确的位置,也许这​​是一个表现。

What I would do is try a different version of mono as described here: http://docs.travis-ci.com/user/languages/csharp/ Maybe try an older one like 3.12 or alpha or beta to try and confirm that this is indeed the issue.

我要做的是尝试不同版本的单声道,如下所述:http://docs.travis-ci.com/user/languages/csharp/也许尝试像3.12或alpha或beta这样的老版本尝试确认这一点确实是个问题。

#1


11  

The travis version is building with an FSharp.Core from the GAC:

travis版本使用GAC的FSharp.Core构建:

-r:/usr/lib/mono/gac/FSharp.Core/4.3.1.0__b03f5f7f11d50a3a/FSharp.Core.dll

Whereas your local build is using the FSharp.Core at:

而您的本地构建使用FSharp.Core:

-r:"/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll"

The error you are getting:

你得到的错误:

FSC: error FS0193: The module/namespace 'System.Net' from compilation unit 'System' did not contain the namespace, module or type 'WebClient'

FSC:错误FS0193:来自编译单元'System'的模块/名称空间'System.Net'不包含名称空间,模块或类型'WebClient'

Indicated a mismatched FSharp.Core where its trying to resolve System.Net references from the Fsharp.Core located in the GAC, the other references in your project are all PCL 259 which will not satisfy this reference.

指示不匹配的FSharp.Core,它试图从位于GAC的Fsharp.Core中解析System.Net引用,项目中的其他引用都是PCL 259,它们不满足此引用。

As to why, could you get travis to build using the diagnostic switch?

至于为什么,你能使用诊断开关进行travis吗?

Ok so following on, now that there is a diagnostic build linked, the problem is here:

好的,接下来,现在已经链接了诊断构建,问题在于:

HintPath /usr/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll does not exist. Reference FSharp.Core resolved to /usr/lib/mono/gac/FSharp.Core/4.4.0.0__b03f5f7f11d50a3a/FSharp.Core.dll. CopyLocal = False Reference found at search path {GAC}

HintPath /usr/lib/mono/xbuild/../参考程序集/ Microsoft / FSharp / .NETCore / 3.259.3.1 / FSharp.Core.dll不存在。参考FSharp.Core已解析为/usr/lib/mono/gac/FSharp.Core/4.4.0.0__b03f5f7f11d50a3a/FSharp.Core.dll。在搜索路径{GAC}中找到CopyLocal = False参考

The travis instance does not have:

travis实例没有:

/usr/lib/mono/xbuild/../Reference Assemblies/Microsoft/FSharp/.NETCore/3.259.3.1/FSharp.Core.dll

So it reverts to the gac.

所以它回归到gac。

There was a recent issue where FSharp.Core was not installed to the correct location, maybe this is a manifestation of that.

有一个最近的问题,FSharp.Core没有安装到正确的位置,也许这​​是一个表现。

What I would do is try a different version of mono as described here: http://docs.travis-ci.com/user/languages/csharp/ Maybe try an older one like 3.12 or alpha or beta to try and confirm that this is indeed the issue.

我要做的是尝试不同版本的单声道,如下所述:http://docs.travis-ci.com/user/languages/csharp/也许尝试像3.12或alpha或beta这样的老版本尝试确认这一点确实是个问题。