Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to directly invoke F# compiler on .NET Core?

UPD.:

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

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.

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.

Env.: macOS, .NET Core 2.2

like image 323
isnullxbh Avatar asked Jul 01 '19 12:07

isnullxbh


People also ask

How do you invoke a function?

The code inside a function is not executed when the function is defined. The code inside a function is executed when the function is invoked. It is common to use the term "call a function" instead of "invoke a function". It is also common to say "call upon a function", "start a function", or "execute a function".

How do you invoke a function in Python?

The way to invoke a function is to refer to it by name, followed by parentheses. Since there are no parameters for the function hello, we won't need to put anything inside the parentheses when we call it.

How do you declare a function and invoke it?

Function expressions can be made "self-invoking". A self-invoking expression is invoked (started) automatically, without being called. Function expressions will execute automatically if the expression is followed by (). You cannot self-invoke a function declaration.


2 Answers

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

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

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

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

like image 179
sdgfsdh Avatar answered Sep 28 '22 04:09

sdgfsdh


After install dotnet core (https://dotnet.microsoft.com/download) you should be able to build a F# project from the command line.

cd my-fs-project
dotnet build
dotnet run
like image 42
Just another metaprogrammer Avatar answered Sep 28 '22 04:09

Just another metaprogrammer