views:

405

answers:

3

I understand MonoDevelop supports MVC and uses an implementation of T4 to generate code.

Is there a way to utilize T4 with my own templates?

I am using MonoDevelop 2.2 Alpha (MonoTouch preview builds) on OSX Snow Leopard. Mono 2.4.2.3 is also installed (which is required for the MonoTouch preview builds).

I have created a very simple .tt file as a test but nothing occurs during the build process, nor are there tool options upon right-click.

+3  A: 

At the moment the T4 engine is only used for ASP.NET MVC scaffolding, and isn't exposed for general-purpose use within MonoDevelop. It would be straightforward to add but I just haven't had time to do it yet.

However, if you poke around in the .app you can find a TextTransform.exe command-line tool for processing templates. Using Preferences->External Tools you could add this to the Tools menu.

mhutch
Thanks, it is helpful to know I wasn't missing something. I'm certainly looking forward to it being generally available! Thanks for your hard work on it thus far, it's great to see it coming together like it has been.
Aaron
+1  A: 

I posted a tutorial on how to do this in Linux on my blog. I'm not familiar with the Mac OS, but something similar should work there as well as on Windows.

Thank you, Mr Hutchinson, for the idea.

dan.s.ward
Your tutorial works using the latest builds of MonoDevelop and the Mono Framework. Be aware that a fresh build is needed, I was using the 2.2 Beta 1 preview of MonoDevelop but it crashed. I am using the Oct 7 MonoDevelop build, and 2.4.3.2 Oct 6 build of the Mono Framework.
Aaron
A: 

Nowadays (with MonoDevelop 2.6) live is much simpler, since there is great support for T4 in the IDE. There is one caveat however. You cannot simply add your existing T4 files to the project and get them auto-generated. You have to go tru the Add/Files dialog, choose Templating and T4 and then copy-paste the content of your existing file into the newly added file.

Richard