How to: Run Text Templates
A text template file contains a mixture of text blocks and control logic. You can use the control logic to combine the text blocks with the data held within a model to produce an output file. There are a variety of uses for text templates. For example, you can generate code or documentation from models. A text template contains both text blocks and control logic. These are read along with the model by the text transformation engine. The engine processes the text template to create the appropriate output file. The output file might be source code, xml, html, or some other deployable software artifact.
Once you have a text template that is ready to use, you can run it as described in the following procedures.
注意
You can also use the VsTextTransform.exe command to run a text template from the command line. For more information, see TextTransform.
To run a single text template file
In Solution Explorer, in the project node, right-click the desired text template file, and then click Run Custom Tool.
For more about running a text template, see Walkthrough: Creating and Running Text Templates.
注意
To debug text templates you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.
To run all text template files in a solution
On the Solution Explorer toolbar, click the Transform All Templates button.
注意
If you created your own template and you do not see the Transform All Templates button on the Solution Explorer toolbar and you want it to appear, conduct one of the following actions:
Invoke the text template by right-clicking on it and selecting Run Custom Tool.
-or-
Add the following into your solution file in the Global section (between the Global and EndGlobal markers):
GlobalSection(TextTemplating) = postSolution TextTemplating = 1EndGlobalSection
Security
For more information, see Security of Text Templates.
See Also
Concepts
Using Built-in Directives in Text Templates