Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does hostspecific signify in a t4 template?

<#@ template debug="false" hostspecific="false" language="C#" #>

What does hostspecific attribute signify here.

like image 558
Vaibhav Jain Avatar asked Mar 14 '13 10:03

Vaibhav Jain


People also ask

How to debug Tt files?

To debug a design-time text template, save the text template file, and then choose Debug T4 Template on the shortcut menu of the file in Solution Explorer. To debug a run-time text template, simply debug the application to which it belongs.

How do T4 templates work?

T4 uses a custom template format which can contain . NET code and string literals in it, this is parsed by the T4 command line tool into . NET code, compiled and executed. The output of the executed code is the text file generated by the template.


1 Answers

A template with hostspecific set to "true" can access a member this.Host of type ITextTemplatingEngineHost (MSDN). You can then use e.g. its method "ResolvePath" in order to locate files needed for input in the template.

This is even more useful when you use a custom templating engine. See Oleg's blog here: http://www.olegsych.com/2008/02/t4-template-directive/

like image 79
Nico Avatar answered Oct 01 '22 04:10

Nico