tags:

views:

68

answers:

2

I'm trying to get T4 to work with ASP.NET, however when I create a textfile and rename it to .tt, I don't get the option to run it

Any ideas?

A: 

Does it not run the transformation when you hit compile ? AFAIK there is no explicit "run transformation" option.

driis
+2  A: 

First off - you can't "run" the file - you can run the custom tool on that file to generate the output.

I would recommend you use Add New Item from your project context menu, and then select Text File and give it a .tt extension right from the beginning. Then the T4 magic works without any hitch - whenever you save the file, or choose Run Custom Tool from the context menu on the file in the Solution Explorer, the template will be converted into its output.

If you have a file where that doesn't work now, do this: select the *.tt file in your Solution Explorer and have a look at the Properties window. In the "Custom Tool" text box, enter the value of TextTemplatingFileGenerator.

alt text

Now, the next time you save your file (Ctrl-S), you should get the output generated behind it.

UPDATE: the issues that the T4 templates don't work in an ASP.NET website project type seems to have been fixed in Visual Studio 2010. See Gareth Jones' blog post What's New in T4 in Visual Studio 2010 for details.

marc_s
That is the issue, inside an ASP.NET website, I am not getting that option, only in ClassLibrary or WinForm projects, does t4 work within an asp.net project?
LeeHull
Thanks.. will convert and try it
LeeHull