Update: the process for building Mono has changed significantly since I first wrote this. You can view updated instructions here.
Ever since I first heard about Mono, I've been fascinated by the potential of .NET to become a viable platform for software that targets multiple OSes. Unfortunately, I've discovered (as seems to be the case with many OSS projects), the documentation aimed towards beginners is quite limited, especially when one ventures away from running Mono on Linux.
I've spent many hours trying to get my development environment for the Mac just right, and at times, it's been a rather painful process. So, in the interest of reducing the pain felt by any beginners following after me, I've decided to start recording my processes for getting things set up. At best, this blog will become a useful resource for anyone doing .NET development on the Mac. At worst...well, at least I'll be able to set things up again the next time I have to wipe a hard drive or replace a machine.
One of the first things that I've found in my work is that the Mono installer available from the Mono Project is rarely sufficient for doing any serious development work: bugs abound in the new parts of Mono (I've found a number of problems in generics), and sometimes, I simply can't resist the urge to dig in and fix them. Therefore, when setting up a new development environment, my first goal is generally to get a custom build of Mono up and running.
Here's how I do it:
The actual work:
~/src/mono. Run the command
svn checkout svn://anonsvn.mono-project.com/source/trunk/mono svn://anonsvn.mono-project.com/source/trunk/mcs. This will download the code for the core Mono libraries and the Mono Compiler System. They'll end up in
cd ~/src/mono/mono && ./autogen.sh —prefix=/opt/mono. This step should get Mono ready to build.
make && make install. I'd love to be able to recommend that you also insert
make checkin that list, but the sad fact is that Mono on MacOS actually fails a number of tests.
After you've done all this, you should have a working (custom) build of Mono working on your machine. You can, at any time, upgrade to the latest code by going to
~/src/mono and running the command
svn update mono mcs. Generally, you'll be able to jump straight to building Mono again, but you may sometimes be required to also run
Also, it's often very handy to have a script around that will set up all of your paths and whatnot to your custom build of mono. The Parallel Mono Environments page on the Mono website describes this, although I had to modify mine a bit to get it working right. Here's what it looks like now:
Mine is stored in
~/mono-dev-env and is invoked via
That's it for my first post on setting up a development environment for Mac/.NET development. In the future, I'll go into setting up mod_mono (for ASP.NET), CruiseControl.NET (you do have unit test you'd like to run regularly, don't you?), and Subversion (I realize that Subversion isn't strictly related to .NET, but I didn't have a Subversion server when I started this project, and trying to figure out how to get it set up wasn't terribly fun).