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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 Itemfrom your project context menu, and then selectText Fileand give it a .tt extension right from the beginning. Then the T4 magic works without any hitch – whenever you save the file, or chooseRun Custom Toolfrom 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.