F# in Mac OS.

"Setting up F# with .NET Core, VSCode and Ionide."

Posted by Nithin VR on 2017-10-02

Introduction to F# in Mac OS

In short we will be setting up in the below order.

  • Install .NET Core.
  • Install VS Code.
  • Install Ionide.

    Installing .NET Core

    Download and install .NET Core SDK from .NET Core for Mac.

    Installing VS Code

    Download Visual Studio Code for Mac and Install.

    Installing Ionide

    Ionide is a plugin to support F# language features for VS Code. Open VS Code, press Cmd+P and enter the command ext install Ionide-fsharp to install the Ionide package.
    Or search ionide in VS Code extensions and install from there.

    Hello World

  1. Create a solution to have multiple projects.
    dotnet new sln --name Everything
    If we did not specify the --name it will take the folder name as the solution name.
  2. Create F# console project and add it to the solution.
    dotnet new console -lang f# -o hwFSharpApp
    In above command -o hwFSharpApp sets an output directory of hwFSharpApp and creates hwFSharpApp.fsproj. console -lang F# will create a console app in F# language.
    dotnet sln add hwFSharpApp/hwFSharpApp.fsproj
    This will add project hwFSharpApp/hwFSharpApp.fsproj to the solution.
  3. Build and run.
    The below command will build the solution with all the projects.
    dotnet build Everything.sln
    To run the console application use the below command with dotnet run which specifies the projects to run.
    dotnet run --project hwFSharpApp/hwFSharpApp.fsproj
    alt text
  4. Use VS Code to edit.
    Using VS Code open the folder with solution(Everything.sln) we created. We can use the F# Project Explorer to Build Run and Debug the F# Projects by setting it as startup project.
    alt text
    Use --help to explore more options in .NET CLI.

    More Details

    1) Use F# on Mac OSX
    2) Get started with F# and .NET Core