I want to create T4 text templates to achieve code generation. All the tutorials I found on msdn suggest following to add a new text template: Add > New Item > Text Template
, (eg https://msdn.microsoft.com/en-us/library/dd820620.aspx) but I don't see that option(Text Template
) there. I am using ASP.NET core 1.0.
Is this issue related to VS2015 or ASP.NET core? If T4 templating is not supported in any of them, what's the best solution/alternative to achieve this?
(I want to generate typescript code from C# code), similar to this tutorial http://dotnetspeak.com/2015/02/typescript-models-creation-via-t4-templates
Include the file into your Visual Studio project. In Solution Explorer, on the shortcut menu of the project, choose Add > Existing Item. Set the file's Custom Tools property to TextTemplatingFilePreprocessor. In Solution Explorer, on the shortcut menu of the file, choose Properties.
Template file created by Visual Studio, a software development tool created by Microsoft; contains both text blocks and control logic used for generating new text files; can be written using Visual C# or Visual Basic code; used for both runtime text generation as well as source code generation.
It was a bug in the visual studio in the early stages.
Now, with Visual Studio 2015 Update 3 (and I think with Update 2 too) I can easily run T4 templates, even in .NET Core / ASP.NET Core projects.
If there isn't the Add > New Item > Text Template option, you can add *.tt files as simple text files.
Give it a try. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With