This will be the first part of a series of 3 articles that will help you to get up and running to do F# development with .NET Core on Linux.
- Part I: Installation
- Part II: Development environment
- Part III: “Hello World” and debugging
Installing .NET Core
The first thing we want to do is to install .NET core. Microsoft provides us with very easy to follow instructions for your favorite distro here.
Once the installation is over you can quickly check that it went well by running the following command.
$ dotnet --version 1.0.4
Installing F#
At this stage we will be able to create, run and build projects but we still don’t have access to the language itself.
For that we will follow the instructions from the F# Foundation located here. One of the biggest benefits of doing so is to have access to the F# interactive tool, which we’ll use now to verify the installation went well by running the following command.
$ fsharpi F# Interactive for F# 4.0 (Open Source Edition) Freely distributed under the Apache 2.0 Open Source License For help type #help;; >
Taking it for a ride
F# Interactive
Let’s use it write a very simple function to see it in action.
Remember that in the context of F# interactive you need to terminate your instructions with ;;
> let add x y = x + y;; val add : x:int -> y:int -> int > add 1 2;; val it : int = 3
Dotnet CLI
The first time you fire up dotnet it will take a few seconds while it bootstraps and prepares its cache.
We’ll create a new console app project which will be the basis for the series.
This will assume you’re running this command inside a folder called fsharp_tutorial and that will be the name of our project as we won’t be specifying one.
$ dotnet new console --language F#
You should now have 2 new files called fsharp_tutorial.fsproj and Program.fs .
Like with any other .NET core project type, we’ll need to restore its packages before can try to do anything useful.
$ dotnet restore
Now we’re ready for the moment of truth as we’ll run our program for the first time.
$ dotnet run Hello World from F#!
If you see the above it means that your installation went as intended and we’re ready for our next step in this series which will be setting up our development environment.
Hey Lucas,
Quick question. To use F# with .NET core on Linux, must we download both the .Net Core SDK and Mono?
Thanks for the awesome article!
Hi Michael, unfortunately at this stage F# interactive only works with mono, however for the language runtime and project you’ll be using .NET Core.
Glad you like the article