Kalekin
Kalekin

Reputation: 41

Configure Visual Studio 2012 to use Mono's C# compiler instead of the default csc.exe

I work in a game engine called Unity3D whose scripting system runs on Mono. By default Unity uses a modified version of Mono to develop/compile script. I am in the process of setting up my Visual Studio to better work with Unity projects and its various gotchas with regards to .NET.

I am currently stuck trying to configure Visual Studio to handle compilation of my various assemblies. Unity uses a modified version of an old Mono compiler, and as such I cannot use the default csc.exe to build assemblies.

My ideal solution would be for Visual Studios's Build Solution option to process my projects with a compiler I point it to, perhaps through configuring the MSBuild (.csproj) file? Falling short of this is there another way I can build from within Visual Studio using Mono's mcs/gmcs compiler?

Upvotes: 4

Views: 1531

Answers (2)

ngreiner
ngreiner

Reputation: 1

I did a project where Unity was running on my Mac and ran Windows/VS2008 on Parallels. In my Visual Studio solution I referenced the appropriate Mono dlls instead of the normal .NET dlls (i.e. System, System.Xml, etc.) and used the typical .. I also wrote all my unit tests using the nUnit dlls provided with the Mono distribution. Since Unity is (or at least was) using just the .cs files, simply copying (via Post Build Script) them into my Unity project structure worked great. Unity would detect the change and update the scripts. This method was very effective, however I was using it about 2 years ago so I'm not sure if it still applies.

In addition it appears that someone went through the trouble of making a video on how to do this: http://forum.unity3d.com/threads/120327-Video-Tutorial-How-to-use-Visual-Studio-for-all-your-Unity-development

Upvotes: 0

levelnis
levelnis

Reputation: 7705

One approach would be to write an MSBuild/PSake script that you could run via a shortcut key from within VS. I've written a blog post about hooking a build script up via a shortcut key. Basically, you would write a batch file that executes the MSBuild script and assign a keyboard shortcut to it, say ALT-1. You would then hit ALT-1 instead of CTRL-SHIFT-B to compile the project.

Upvotes: 2

Related Questions