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?
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?
Does it not run the transformation when you hit compile ? AFAIK there is no explicit "run transformation" option.
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
.
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.