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

7 Comments

  1. Istvan Kurta says:

    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:
    - https://github.com/freebsd-haskell/freebsd-haskell/blob/master/README.md
    - http://www.mono-project.com/Mono:FreeBSD
    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

    Greetings!

  2. David Southwell says:

    PS I should have said the error came after attempting to run portshaker!

  3. David Southwell says:

    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:
    mirror_base_dir="/var/cache/portshaker"
    ports_trees="main"
    main_ports_tree="usr/ports"
    main_merge_from="freebsd"

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

    David

    • Rhyous says:

      Wow, I haven't done this in a while. Maybe check with the mailing list: mono@FreeBSD.org

    • Rodney Willis says:

      David,

      Did you ever find a solution to this?

      Thanks,
      Rodney

      • Istvan Kurta says:

        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:
        - https://github.com/freebsd-haskell/freebsd-haskell/blob/master/README.md
        - http://www.mono-project.com/Mono:FreeBSD
        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

        Greetings!

Leave a Reply

How to post code in comments?