本文介绍了如何在 .NET Core 上直接调用 F# 编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:

我想直接从 .NET Core SDK 调用 F# 编译器(即 fsc).

I want to invoke F# compiler (i.e. fsc) from .NET Core SDK directly.

我了解 dotnet build &co,但是当我只需要编译一个简单的问题时,我不想涉及它们,即在 fsc file.fs 就足够的情况下.

I know about dotnet build & co, but I don't want to involve them when I only need to compile a simple problem, i.e. in cases when fsc file.fs would be enough.

我尝试在 .NET Core SDK 中搜索(在我的 Mac 上,它位于/usr/local/share/dotnet/sdk/2.2.102/FSharp)并在那里找到了一个 fsc.exe 文件.不幸的是,当我尝试使用 dotnet/usr/local/share/dotnet/sdk/2.2.102/FSharp/fsc.exe 启动它时,它给了我一个错误:

I've tried to search in .NET Core SDK (on my Mac, it was in /usr/local/share/dotnet/sdk/2.2.102/FSharp) and found a fsc.exe file there. Unfortunately, when I try to start it with dotnet /usr/local/share/dotnet/sdk/2.2.102/FSharp/fsc.exe, it gives me an error:

error FS0193: Could not load file or assembly 'Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

环境:macOS、.NET Core 2.2

Env.: macOS, .NET Core 2.2

推荐答案

可能不想直接调用 fsc,因为 dotnet buildfsproj 是构建项目的首选方式.

You probably don't want to call fsc directly, since dotnet build and fsproj is the preferred way of building projects.

如果你必须,那么它可以在 SDK 文件中找到:

If you must though, then it can be found in the SDK files:

dotnet /usr/share/dotnet/sdk/5.0.100/FSharp/fsc.exe

使用 dotnet --list-sdks 查找 SDK 的完整路径.

Use dotnet --list-sdks to find the full path to your SDK.

这篇关于如何在 .NET Core 上直接调用 F# 编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:59