Using T4 I want to generate some code based on examining what files are in a directory relative to the template file being executed.
Is there a way in c# to identify what the path of the current template file is?
Using T4 I want to generate some code based on examining what files are in a directory relative to the template file being executed.
Is there a way in c# to identify what the path of the current template file is?
You need to set the hostspecific property of the template directive to True. This will make T4 generate a special property called Host, which gives you access to ResolvePath method and TemplateFile property. You can find details here: http://www.olegsych.com/2008/02/t4-template-directive/