Installing the latest version of Mono on FreeBSD or How to install and use portshaker?

Mono is basically the .NET Framework on FreeBSD or other open source platforms. This allows development in C# on FreeBSD.  C# is an extremely popular language that is not slowing down.  It’s popularity stems from that fact that this language and its features allows for rapid development that is much faster than many other languages.

The version of Mono available in the ports tree is not the latest version available. Just like FreeBSD has a release version and a development version, Mono has a release version and a development version.  The development version is so much newer that it is hard not to recommend it over the release version.

Step 1 – Install the latest ports

This is already documented here:

How to install ports on FreeBSD?

Step 2 – Install portshaker and portshaker-config

The team at BSD# have a tool called portshaker that adds mono ports to the ports tree.  Install it as follows.

cd /usr/ports/ports-mgmt/portshaker-config
make BATCH=yes install

Note: Notice I didn’t just install portshaker, I installed portshaker-config which has portshaker as a dependency, so you get both installed with one command.

Step 3 – Configure portshaker

The example portshaker.conf.example is configured correctly for default configurations, so all we need to do is copy it.

# cp /usr/local/etc/portshaker.conf.example /usr/local/etc/portshaker.conf

Step 4 – Run portshaker

Yes, it is that easy.  Simply run portshaker.

# portshaker

Note: You may be prompted to merge a few files. I diffed and chose either install or continue each time.

Note: Running portshaker uses subversion to download so if you need to use an HTTP proxy, you have to configure subversion to use an HTTP proxy as it doesn’t use the FreeBSD HTTP_PROXY environment variable.

Your ports tree is now updated by portshaker.

Step 5 – Install mono

The mono port should now be updated to the latest version.

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

Mono is now installed on your system.

There is an example of building a hello world app here:

C# (Mono) on FreeBSD

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Hi there!

    I have managed somehow to get it working. In the portshaker.conf file under /usr/local/etc/portshaker.conf, i have changed the main_merge_from value from “freebsd” to “ports bsd_sharp”. When running portshaker some conflicts will pop up, there i have selected the install option.
    Source of information:
    The file bsd_sharp can be found under the following location: /usr/local/etc/portshaker.d/
    I hope this will help. This way i was able to run portshaker and after that to install mono with the following commands:

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


  2. After following these instructions I get the following:
    /usr/local/etc/portshaker.d/freebsd: not found

    In following the instructions it should be noted:
    the file portshaker.conf.example does not exist but portshaker.conf.sample does so cp was done using.conf.sample

    the relevant lines in portshaker.conf seem to be:

    It looks as though main_merge_from may be incorrectly defined.l How should that read?