Can I compile .NET C# code on my Mac?

I need a way to cross compile a short piece of .NET C# code to a dll, which will then run a client's Windows environment.

I run OS X 10.9.2 on an iMac.

Does anyone know what tools allow this?

I would rather not install Parallels and Windows if I can find a way to cross compile this without needing that heavy of an installation of Microsoft tools.


Solution 1:

Check out the Mono Project. It may be what you are looking for.

http://www.mono-project.com/Mono:OSX

MonoDevelop is a cross-platform IDE primarily designed for C# and other .NET languages. MonoDevelop enables developers to quickly write desktop and ASP.NET Web applications on Linux, Windows and Mac OSX. MonoDevelop makes it easy for developers to port .NET applications created with Visual Studio to Linux and Mac OSX maintaining a single code base for all platforms.

Solution 2:

You can install it with homebrew:

brew install mono

Then you can use it with:

mcs hello.cs
mono hello.exe

Solution 3:

If you have a Mac you can compile C# like this:

Compile: mcs fileName.cs
Run: mono fileName.exe

If you don't have Mono installed on your Mac, you can google it and install it and then you will be good to go. You don't need Windows to do this.

Solution 4:

No personal experience with this IDE but this looks like it will work: http://monodevelop.com