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:
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets
around line 145, and delete these two lines:
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
and around line 166, change these two lines:
ToolExe="$(CscToolExe)"
ToolPath="$(CscToolPath)"
to this:
ToolExe="gmcs.bat"
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.)
If you go to:
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets
around line 145, and delete these two lines:
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
and around line 166, change these two lines:
ToolExe="$(CscToolExe)"
ToolPath="$(CscToolPath)"
to this:
ToolExe="gmcs.bat"
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.)
Comments
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.
As stated above, just override the values after the targets file is included.
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.