VisualStudio MacOS是否使用与dotnet / Rider不同的F#编译器?

问题描述

我正在尝试在Mac上编译FsPickler。

命令行编译效果很好:

dotnet build -c Release

但是在Visual Studio(版本8.8)中编译同一项目时,我开始遇到一些与文件解析有关的编译错误,这确实很奇怪。

喜欢这种错误

enter image description here

它无法编译的代码是这样的:

let currentLoadContext = lazy(
    match Type.GetType "System.Runtime.Loader.AssemblyLoadContext" with
    | null -> None
    | ty ->
        match ty.GetProperty "Assemblies" with
        | null -> None // property not available in netcoreapp < 3.0
        | assembliesProperty ->
            let loadContextM = ty.getmethod("GetLoadContext",BindingFlags.Public ||| BindingFlags.Static,null,[|typeof<Assembly>|],null)
            let loadFromNameM = ty.getmethod("LoadFromAssemblyName",BindingFlags.Public ||| BindingFlags.Instance,[|typeof<AssemblyName>|],null)
            let asm = Assembly.GetExecutingAssembly()
            let currentLoadContext = loadContextM.Invoke(null,[|asm|])
            let getContextAssemblies () = assembliesProperty.GetValue(currentLoadContext) :?> seq<Assembly> |> Seq.toArray
            let loadFromAssemblyName (an : AssemblyName) = loadFromNameM.Invoke(currentLoadContext,[|an|]) :?> Assembly
            Some {| LoadContext = currentLoadContext ; GetCurrentAssemblies = getContextAssemblies ; LoadFromAssemblyName = loadFromAssemblyName |})

但这与问题并没有真正的联系。

当我查看细节时,会发现:

Target CoreCompile:
        /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/fsharp/fsc.exe -o:obj/Debug/netstandard2.0/FsPickler.dll

现在我在问:为什么我什至还要安装Mono,Mono与使用Visual Studio编译.net代码有什么关系?

如果我使用Rider编译相同的项目,则可以使用命令行运行,但是可以使用Visual Studio读取上述错误,并且编译器来自Mono文件夹。

任何人都可以弄清楚为何要使用Mono以及是否有两个版本的编译器吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)