简体   繁体   中英

Running Dotnet F Sharp Compiler from Command Line on Mac

I am going through this tutorial but do not have fsc (F Sharp Compiler). Running dotnet fsc -a MyAssembly.fs shows:

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-fsc does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Running ls /usr/local/share/dotnet/sdk/3.0.100/FSharp shows:

FSharp.Build.dll                          fsc.exe
FSharp.Compiler.Interactive.Settings.dll  fsc.runtimeconfig.json
FSharp.Compiler.Private.dll               fsi.deps.json
FSharp.Core.dll                           fsi.exe
Microsoft.FSharp.NetSdk.props             fsi.runtimeconfig.json
Microsoft.FSharp.NetSdk.targets           it
Microsoft.FSharp.Overrides.NetSdk.targets ja
Microsoft.FSharp.Targets                  ko
Microsoft.Portable.FSharp.Targets         pl
cs                                        pt-BR
de                                        ru
default.win32manifest                     tr
es                                        zh-Hans
fr                                        zh-Hant
fsc.deps.json

which has fsi.exe and fsc.exe . I would believe this would mean dotnet fsc would exist.

Additionally, I have mono from this guide so fsharpc and fsharpi work.

The guide is a bit old. This Stack Overflow question discusses that we usually don't directly use fsc.exe but rather create a project and use the .NET Core CLI ( dotnet ) to build and run F# projects. There is a getting started guide for using the .NET Core SDK which should help you with that.

Regarding the usage of dotnet fsc there is a discussion thread about it on GitHub. As far as I know the fsc keyword is - contrary to the things discussed - not implemented. The fsi keyword is, though. You can still use fsc.exe directly. Just call dotnet <full-path-to-fsharp-sdk-location>/fsc.exe . As mentioned above - there is usually no need to call fsc directly other than very special tasks or honest curiosity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM