Jan 12, 2010

Custom T4 host for asp.net mvc

T4 template can be hosted by different environment. By default template is not HostSpecific. When you want to reuse a template to generate different file, you can customize the generation process by providing a dialog window. This is what MvcTextTemplateHost does. ASP.NET MVC tools is included in C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Microsoft.VisualStudio.Web.Extensions.dll , which is not a open source project. But you can use Reflector to view some of its implementation. The dll provide some context menu to add view , add controller , and some dialog box for use to customize the code generation. Here is article about the MvcTextTemplateHost