Install Mono 2.10.8 from Source on Ubuntu with a Bash Script

NOTE: Badgerports.org is now current w/ 2.10.8.1. This bash script is more useful when installing parallel Mono, when a new version is released and not yet published on badgerports, or if you simply want to compile it yourself from source. I highly recommend trying Badgerports first.

Install

mkdir mono-2.10
cd mono-2.10
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.10.sh
chmod 755 install_mono-2.10.sh
./install_mono-2.10.sh

 

Enjoy!

Update 12/30/2011 – Updated Mono 2.10.6 to 2.10.8.0

Update 10/16/2011 – Updated Mono 2.10.5 to 2.10.6

Update 8/31/2011 – Updated Mono 2.10.4 to 2.10.5

Update 8/11/2011 – Updated Mono 2.10.3 to 2.10.4 for minor update.

41 thoughts on “Install Mono 2.10.8 from Source on Ubuntu with a Bash Script

  1. Hi,
    thank you for this install script. Mono is now running correctly.

    But please let me ask you a question. Is it possible to run more ASP.NET MVC projects with one public IP and no domain? Let say I have public IP 123.123.123.123 and one project would be accessable at 123.123.123.123/projectone and the second at 123.123.123.123/projectsecond.

    Is it possible? If so, what should I do to make it running?
    Thank you very much.

  2. I ran the scripts on my kubuntu 11.04, but mono -V still reports that it is at version 2.6.7… how can I fix this?

  3. Update: I figured out it installed correctly, but I need to type /opt/mono-2.10/bin/mono rather than just mono… is there a way to fix this? If not I can live with it as is

  4. @Iceman That’s a good question. I think it’s more related to how Apache (if that’s your server) handles setting up virtual hosts / aliases. I personally use one IP for testing with many domains. Using virtual hosts by name, I can separate traffic into multiple Asp.NET runtimes (MVC applications) easily.

    Checkout the ServerPath directive. (here’s an old example in 1.3 at the bottom) where they setup matching virtual hosts, but a server path would route traffic for a sub-directory in the quest and pass it to another virtual host.

  5. @Domos123

    That’s normal. My script doesn’t install to the default system path (so it doesn’t break any existing platform packaged apps).

    Part of the Parallel Mono Environments suggestion is to setup an environment per app to use this. Here’s an example for a terminal session:


    #!/bin/bash
    MONO_PREFIX=/opt/mono-2.10
    GNOME_PREFIX=/usr
    export DYLD_LIBRARY_FALLBACK_PATH=/lib:
    export LD_LIBRARY_PATH=/lib:/opt/mono-2.10/lib:
    export C_INCLUDE_PATH=/include:/include
    export ACLOCAL_PATH=/share/aclocal
    export PKG_CONFIG_PATH=/lib/pkgconfig:/lib/pkgconfig
    export PATH=/bin:/opt/mono-2.10/bin:$PATH

    Also, you can see more in another post I did on setting up MVC3. It describes how to configure your virtual host to use this custom environment to run this version of Mono.

    Using /opt/Mono-vvv allows you to run many versions of mono at the same time. That way when new versions come out, you can install them safely without breaking existing application dependencies. I’m installing to prefix /mono-2.10; but you could install to 2.10.4 if you wanted to be a little safer. This will also be non-intrusive to your platform-packaged version of mono so packaged dependencies don’t break.

    Hope that helps!

  6. @Domos123

    I left a few things out. To use that bash script in a terminal, first save the script above to a file, “mono-env.sh” for example. Then in a terminal enter:

    source mono-env.sh

    This will load up the env for you. You can also rope that script into other scripts. The monoDevelop script I pushed out awhile back does this for the launcher so MonoDevelop can use this environment even when it’s not the platform-default.

    If you want platform default; try out Fedora 15+ ;) I hear that Ubuntu 11.10 will be packaged with 2.10.2, which will be a nice bump from 2.6.7.

  7. @Nathan
    Thanks for answer. I solved it by buying one domain. It’s not expensive, so it’s ok ;)

    But I have another question. I want to have always the newest version of Mono. But now, I have 2.10.3. Can I use the updated script to update Mono to version 2.10.4?

  8. @Iceman
    Nice, Glad you got it working! I sometimes setup test subdomains for sites too just to separate traffic.

    Yeah, the upgrade script should work now the same between .2 to .3 and .3 to .4. The only changed packages are mono and gtk-sharp. This script should do it. Although, my disclaimer is that it appears the old gtk doesn’t remove, so try removing that by hand first. Download/run this script from the same location you ran the last one (so it can auto remove the old mono package). (worked on my machine). ;)

    Just in case… If it fails, just blast /opt/mono-2.10 and re-install using the full install script. ;)

  9. HI!
    thanks for your script!
    just one question: I cannot make monodevelop start using the version of mono installed with this script.
    I’ve created the mono-env.sh script, but… where (and how) I should call it from monodevelop.sh?

  10. @Nathan
    The script didn’t work for update .3 to .4. This is the error message:

    ./upgrade_mono-2.10.2-2.10.4.sh: line 38: cd: /opt/mono-2.10/build/mono-2.10.2: No such file or directory

    There’s no “mono-2.10.2″ directory, just “mono-2.10.3″. But I’ve deleted the “mono-2.10″ directory, run full install script and it’s working great with Mono 2.10.4.

    Thanks ;)

  11. @dg1974 The sample monodevelop.sh script I provided should have setup your environment already. One of my suggestions (if you want to build your projects from an interactive terminal), is to setup an environment script like that and then use source yourscript.sh to load it up.

    If you run the monodevelop.sh script, does it not work?

  12. @Nathan
    sorry, but where can i find the sample monodevelop script?

    if i run the mono-env.sh i can run mono.exe correctly (version 2.10.4).
    but if from that terminal I run monodevelop I receive a bunch of error (about missing mozilla references and so on).
    so I think to edit the monodevelo.sh to use that mono-env.sh correctly but I don’t know how.

  13. Here’s mine. Did you get any build errors for 2.10.4? Are you running Gnome3? (If so, I don’t think this MonoDevelop install works for Gnome 3 yet).


    #!/bin/bash
    MONO_PREFIX=/opt/mono-2.10
    GNOME_PREFIX=/usr
    UBUNTU_MENUPROXY=
    export DYLD_LIBRARY_FALLBACK_PATH=/lib:
    export LD_LIBRARY_PATH=/lib:/opt/mono-2.10/lib:
    export C_INCLUDE_PATH=/include:/include
    export ACLOCAL_PATH=/share/aclocal
    export PKG_CONFIG_PATH=/lib/pkgconfig:/lib/pkgconfig
    export PATH=/bin:/opt/mono-2.10/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

    monodevelop

  14. I get this error if I run the script posted before:
    WARNING: Cannot find Mozilla directory containing libgtkembedmoz.so. Some Addins may not be able to function. Please set MOZILLA_FIVE_HOME to your Mozilla directory.

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756′ or one of its dependencies.
    File name: ‘Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756′
    [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly ‘Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756′ or one of its dependencies.
    File name: ‘Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756′
    Missing method get_IsInitialized in assembly /usr/lib/monodevelop/bin/MonoDevelop.exe, type Mono.Addins.AddinManager

    Monodevelop started from the menu works correctly (with default mono 2.6.7) and I can build and run mono app with 2.10.4 (installed with your script).
    I’m using Ubuntu 11.04.

  15. @dg1974 I recall this being a pain point for Ubuntu Natty. The mozilla dependency was upgraded in Natty and Addins (I believe) referenced the older version.

    Nonetheless, try downloading source for Mono.Addins and compiling it. If you’re using the 2.10.4 script, I don’t think it’s included with that. It should be in the MonoDevelop script though, but I haven’t updated it in awhile so it may be lagging behind a version or two.

    (while writing this, I realize 2.10.5 has been released; doh!). I’ll work on the next version and post it soon. I’ll also look at updating the MonoDevelop scripts for ubuntu and see how well it fares w/ the latest packages on Natty.

  16. Thanks for the install scripts! I’ve had much trouble installing MonoDevelop in the past. I’ve updated the script to install from 2.6.0.1 sources as opposed to 2.6 beta 1. Not sure whether can inline a diff properly in comments, but will try:

    *** install_monodevelop-2.5.90.sh 2011-09-19 06:39:14.412491214 -0700
    — install_monodevelop-2.6.0.1.sh 2011-09-19 06:55:34.252491254 -0700
    ***************
    *** 28,36 ****
    “mono-debugger-2.10″
    “mono-tools-2.10″
    “gnome-sharp-2.24.1″
    ! “monodevelop-2.5.90″
    ! “monodevelop-debugger-gdb-2.5.90″
    ! “monodevelop-database-2.5.90″
    “gluezilla-2.6″
    )

    — 28,36 —-
    “mono-debugger-2.10″
    “mono-tools-2.10″
    “gnome-sharp-2.24.1″
    ! “monodevelop-2.6.0.1″
    ! “monodevelop-debugger-gdb-2.6.0.1″
    ! “monodevelop-database-2.6.0.1″
    “gluezilla-2.6″
    )

    ***************
    *** 38,46 ****
    “http://ftp.novell.com/pub/mono/sources/mono-debugger/mono-debugger-2.10.tar.bz2″
    “http://ftp.novell.com/pub/mono/sources/mono-tools/mono-tools-2.10.tar.bz2″
    “http://ftp.novell.com/pub/mono/sources/gnome-sharp2/gnome-sharp-2.24.1.tar.bz2″
    ! “http://ftp.novell.com/pub/mono/sources/monodevelop/monodevelop-2.5.90.tar.bz2″
    ! “http://ftp.novell.com/pub/mono/sources/monodevelop-debugger-gdb/monodevelop-debugger-gdb-2.5.90.tar.bz2″
    ! “http://ftp.novell.com/pub/mono/sources/monodevelop-database/monodevelop-database-2.5.90.tar.bz2″
    “http://ftp.novell.com/pub/mono/sources/gluezilla/gluezilla-2.6.tar.bz2″
    )

    — 38,46 —-
    “http://ftp.novell.com/pub/mono/sources/mono-debugger/mono-debugger-2.10.tar.bz2″
    “http://ftp.novell.com/pub/mono/sources/mono-tools/mono-tools-2.10.tar.bz2″
    “http://ftp.novell.com/pub/mono/sources/gnome-sharp2/gnome-sharp-2.24.1.tar.bz2″
    ! “http://download.mono-project.com/sources/monodevelop/monodevelop-2.6.0.1.tar.bz2″
    ! “http://download.mono-project.com/sources/monodevelop-debugger-gdb/monodevelop-debugger-gdb-2.6.0.1.tar.bz2″
    ! “http://download.mono-project.com/sources/monodevelop-database/monodevelop-database-2.6.0.1.tar.bz2″
    “http://ftp.novell.com/pub/mono/sources/gluezilla/gluezilla-2.6.tar.bz2″
    )

  17. @Jonathan Shore
    Thanks man! You guys rock! Someone else also just posted a pull request on github recently with these updates. Go take a look at the new scripts and let me know what you think. I merged them in but haven’t tested them myself yet. Go take a look!

    The best way to contribute is to fork my repository in github, make your changes and submit a pull request. You get your name attached to the code, and we all benefit from the updates more frequently. Everyone wins!

  18. Hi Nathan,
    do you have heard from somebody using mono (2.10.x) on a RHEL 6.x installation?
    (do you think this may be possible using your “adapted” installation scripts?)
    Thanks Jon Duri

  19. @Jon

    Anything is possible. I would fire up a virtual with VirtualBox or whatever VM you like and try it. Use the Fedora version from GitHub (which is updated, but I haven’t posted here about it).

    Most-likely if you have any problems, it’ll be related to the dependencies. So if anything is too old for the system, you may be able to download those dependencies and install them manually too. If you get it working, post back here and let me know. I’m curious.

  20. Hi Nathan,
    the script executed perfectly on a rhel 6.x os. We shall check function in the next days.
    thanks and regards Jon Duri

  21. Gracias por este gran manual, me sirvió de mucho!

    @ Domos123, mira para crear un enlace simbólico tienes que usar el comando LN, yo te lo dejo aqui y tu lo editas si has cambiado los parámetros:

    ln -s -f /opt/mono-2.10/bin/mono /usr/bin/mono

    Esto hará que cuando escribas ‘mono’ en la consola te funcione, para mirar si todo esta bien despues de ejecutar el comando escribe; mono -V, y te irá, gracias.

  22. The install instructions worked fine on ubuntu natty (11.04) up to the last command. On entering this, several 404 errors were generated and mono was not updated (checked using mono -V ). If any more information is required to resolve this then please let me know. The errors produced were as follows.

    W: Failed to fetch http://ppa.launchpad.net/aleseftimie/ppa/ubuntu/dists/natty/main/source/Sources 404 Not Found

    W: Failed to fetch http://ppa.launchpad.net/aleseftimie/ppa/ubuntu/dists/natty/main/binary-i386/Packages 404 Not Found

    W: Failed to fetch http://ppa.launchpad.net/team-xbmc/ppa/ubuntu/dists/natty/main/source/Sources 404 Not Found

    E: Some index files failed to download. They have been ignored, or old ones used instead.

  23. Hi @Chris

    The install probably did go through, but you have to configure your runtime environment to use them. These scripts use the recommendation for parallel Mono environments so it doesn’t affect your platform packaged versions. Peek at this comment

    I’m not familiar with those PPA’s and they’re not a part of my install script. Could they be a part of another installation? XBMC? The 404′s are likely caused by something else.

  24. @John

    Apologies. I haven’t actually updated the MonoDevelop script for quite awhile. (beta 2 or 3 I believe). I had to hard wire the xul-runner for pre 11.04 ubuntu to work. I will definitely update it at some point.

  25. @Nathan

    No need to apologize. Just wanted to let you know. You can either hard wire your script for 11.04 like you suggest… or just wait for 11.10′s package, although I don’t know how long it might be until it’s available.

    Should you update the script to use the 11.04 repo, I would download it today and use it. =)

  26. Hi @Oscar,

    Sorry for the delay on this. This script will do a few things. First: delete /opt/mono-2.10 (default prefix), which is where all the mono files will be installed to. Second, you can “reverse” the apt-get install by doing: “apt-get remove “. (That’s kind of a guess, but if you’re starting with a fresh machine and you’re wanting to roll back all the dependency installed added by the script). You may have to follow that up with “apt-get autoremove” to clean up.

    That should be it. I think the major piece is the mono install itself which is super easy to clean up since the script prefixes that to a custom directory.

    Hope that helps!

  27. Hi @Anthony,

    Well if you’re using the script (outdated currently), then it will install to the prefix: /opt/mono-2.10, but if you’re installing with badgerports, then it will install to the system default prefix: /usr/

    The prefix is just the starting directory for the rest of the install path. So when you install Mono and other applications, typically, you’ll get the binaries in /bin and static and dynamic libraries in /lib, header files for dev in /include, etc. Setting ai prefix, helps organize the target install a little bit. So with this install script (above), you could safely, completely remove mono by just “rm-rf /opt/mono-2.10″. It would blast that directory and everything beneath it, which is not the case for /usr.

    Take a look at my post about installing to AWS, which delves a little deeper into using badgerports step by step. I would highly recommend that solution first. (This script is good when the mono releases are super fresh and badgerports hasn’t updated yet).

  28. Okay that helped me to understand better. I am proficient in the use of ppa’s so I will give that a go. After adding the badger report repo am I safe to just apt-get install mono?

  29. @Anthony Yeah I think so. They break the packages down a little bit, so you may have to include a few extras depending what you want.

    I typically use: “mono-apache-server4 mono-devel libapache2-mod-mono” to get .net 4 dev tools + web. (I have a slick git push hook that builds my code on deploy for a project). You could otherwise use the lighter “mono” instead of “mono-devel”

  30. Thanks so much for this script. Is there a way to get Ubuntu to recognize that the upgraded mono has been installed? For example when using apt-get or Software Center to try to install something that requires mono 2.10, it tells me that it is an unresolvable dependency, even though I have it installed. This happens even if I change the prefix in the script to install over top of the system mono.

  31. @Lee You bet! I’m glad it helps!

    Well if you’re only needing 2.10.x, then I would suggest using the back port, which wires itself into the package management system. Below, there’s a snippet of commands you can enter to enable it. This script is probably outdated now that 2.9 is live and 2.11 is available. I just posted a script for 2.11. You can also keep a close eye on my github iws-snippets project to see when I update the scripts.

    There is no way to wire this in as a dependency for other packages in the system package manager. But, you can use it as the default mono by tweaking your environment settings a little. This scripts intended to be a barebones web server install, and you would tweak the environment settings of the virtual host to use the prefix you installed to (in this case /opt/mono-2.10). It allows you to run multiple versions of mono side-by-side. The only downside is that you don’t get to use any system packages with it.

    Quick install from badgerports:

    wget http://badgerports.org/directhex.ppa.asc
    sudo apt-key add directhex.ppa.asc
    sudo apt-get install python-software-properties
    sudo add-apt-repository 'deb http://ppa.launchpad.net/directhex/ppa/ubuntu lucid main'
    sudo apt-get update
    sudo apt-get install mono-apache-server4 mono-devel libapache2-mod-mono

    Hope that helps!
    -Nathan

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>