Option 1: Build and install the F# runtime, compiler and tools from the FreeBSD ports collection

The commands for steps 1-4 must be run as ‘root’, e.g., using su.

  1. Update your local copy of the ports collection:

    If this is the first time you’re running portsnap on your system (e.g., you’ve just installed FreeBSD), you’ll need to fetch a complete copy of the ports collection:

    portsnap fetch extract

    Otherwise, you can just update your local copy of the ports collection:

    portsnap fetch update
  2. Build and install Mono:

    If you do not have an existing Mono installation, you can just build and install the latest version:

    cd /usr/ports/lang/mono
    make install clean BATCH=yes

    If you already have an older version of Mono installed on your system, you must de-install the existing version before installing the new version:

    cd /usr/ports/lang/mono
    make deinstall
    make install clean BATCH=yes

    NOTE : Mono is dependent on several other ports, which will automatically be compiled and installed (if necessary) before proceeding with the Mono build/installation. The BATCH=yes option tells make to configure these dependencies using their default build settings; if you want to modify these settings, leave this option off.

  3. Build and install the F# compiler (open edition) and libraries:

    cd /usr/ports/lang/fsharp
    make install clean BATCH=yes
  4. F# is now installed on your system. Confirm the installation was successful by launching F# interactive:


    If you’re greeted with the F# interactive shell, the installation was successful – type #quit;; and press ENTER to exit.

Using F# on FreeBSD

Once installed, use fsharpi to start F# Interactive, and use fsharpc to compile.

fsharpi     (starts F# interactive)
fsharpc     (F# compiler)
xbuild      (Builds .fsproj projects and .sln files, including ones authored in Visual Studio)

If running F# interactive in Emacs or another similar environment, use

fsharpi --readline-

to turn off console processing.

Editing tools

Some editors have specific support for F#, either builtin or through addons provided by the F# community: