Text templates are a feature of Visual Studio that allow you to generate program code or other text files through a transformation process. Using Visual Studio SDK, you can extend the default template transformation process by customizing the text template directive processor or the text template host.
The directive processor deals with directives in your template, such as <#@template#>. It runs during the compilation of the template, and can load assemblies and other resources. It can also insert code that will load resources at runtime. By defining your own directive processor, you can reduce the complexity of your templates.
If you are writing a Visual Studio Extension such as a menu command or event handler, your extension can use the Text Templating Service to transform any text template. You can pass parameter data into the template by using the Session object, and get the values from within the template by using the <#@parameter#> directive.
When the code of the text template executes, the host provides access to external files and the state of the application. For example, the host that runs text transformations in Visual Studio can provide access to solution explorer. It also displays errors in the error message window. If you want to run text transformations in a different context, you can define your own host that provides access to the services available in that context.
If you are writing a Visual Studio Extension, consider using the existing text transformation service instead of writing your own host. For more information, see Invoking Text Transformation in a Visual Studio Extension.