How to include a custom utility class with our T4 templates generators ? I tried adding a module to the project but it seem there is no way to include it for my generators to use the methods from it.
Thanks.
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.
You cannot access any code that is in your project, from your template. Even if you could, how would it execute? The template is executed at design time.
Use the Inherits directive, give the name of your utility class. http://technet.microsoft.com/en-us/query/bb126474 See ‘Using a different set of utility methods’. Your class will need to inherit from Microsoft.VisualStudio.TextTemplating.TextTransformation
That, or you can build your module into an assembly, then reference the assembly from within the template
or you can simply put your utility methods in a class feature block in another template then include it in your main template