gmcs in Visual Studio

I was trying to learn a bit about MSBuild today and how things get built in Visual Studio, and I came across a cute little hack. I may be the last person in the world to discover it, but I still thought it was neat.

If you go to:

around line 145, and delete these two lines:

and around line 166, change these two lines:

to this:
ToolPath="C:\Program Files (x86)\Mono-2.2\bin"

(your ToolPath may vary)

when you build your C# projects in VS2k8, it will build them with Mono's C# compiler "gmcs" instead of Microsoft's "csc" compiler.

(If you try this, you should of course backup your Microsoft.CSharp.targets file.)


vamsi said…
Thanks for the info, It's really good
Keith J. Farmer said…
Since $(foo) simply returns the value of $(foo), you might do better to search for value, and replace the value there.

Properties are also last-definition-wins. You can use this to override values set by target files encountered earlier. In effect, you should be able to create a simple targets file for mono that inject such reassignments into the standard targets file without damaging it otherwise.

You *could* ship such a targets file. Microsoft did something like this for the DLinq preview.
Anonymous said…
Please don't modify these files, instead you should edit each .csproj.

As stated above, just override the values after the targets file is included.
Dries said…
In reply with what 'Anonymous' said you would better copy the Microsoft.CSharp.targets (name it Mono.CSharp.targets) and modify this file. In your projects replace the microsoft with the new one. Secondly remove the automatically reference assembly as one of them gives an error.

With the create template of visual studio you could easily make mono templates and create mono project like it were normal projects.

So thanks for sharing your insights ... now lets try to build MonoDevelop like Hutchinson did.

Popular posts from this blog

Introducing Pinta

Pinta 1.0 Released

Mono in Visual Studio 2010