Total Pageviews

Disclaimer

This is a personal web page. The views expressed on this blog are mine and do not necessarily reflect the views of my current employer.

I am currently employed by Morgan Stanley.

April 21, 2012

How to Transform T4 files (.tt) without Visual Studio

Microsoft integrates T4 text template support inside Visual Studio. However, you usually find it troublesome to transform such files outside Visual Studio (at command prompt or in your build process). In fact, you can even transform them without installing Visual Studio, because...Mono guys have a full open source implementation of that engine :) Then how should you make use of the Mono assistance?
  1. Visit MonoDevelop source repository and grab two C# projects named Mono.TextTemplating and TextTransform, https://github.com/mono/monodevelop/tree/master/main/src/addins/TextTemplating
  2. Create a solution file and add these two. Compile them and now check the output of TextTransform project.
This project gives you a command line utility called TextTransform.exe. About how to use it, simply execute it without any parameter and read its help. If you are familiar with Mono.Options, you can even learn that from its entry function, https://github.com/mono/monodevelop/blob/master/main/src/addins/TextTemplating/TextTransform/TextTransform.cs
Good luck.