Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 4.46 KB

generating-files-with-the-texttransform-utility.md

File metadata and controls

74 lines (52 loc) · 4.46 KB
title description ms.date ms.topic helpviewer_keywords author ms.author manager ms.subservice
Generating Files with the TextTransform Utility
Transform a text template with the TextTransform utility command-line tool, and use optional parameters to identify the assembly, directive processor, and namespace.
07/26/2019
conceptual
text templates, TextTransform utility
TextTransform.exe
mgoertz-msft
mgoertz
mijacobs
modeling

Generate files with the TextTransform utility

TextTransform.exe is a command-line tool that you can use to transform a text template. When you call TextTransform.exe, you specify the name of a text template file as an argument. TextTransform.exe calls the text transformation engine and processes the text template. TextTransform.exe is usually called from scripts. However, it is not usually required, because you can perform text transformation either in Visual Studio or in the build process.

Note

If you want to perform text transformation as part of a build process, consider using the MSBuild text transformation task. For more information, see Code Generation in a Build Process. In a machine on which Visual Studio is installed, you can also write an application or Visual Studio Extension that can transform text templates. For more information, see Processing Text Templates by using a Custom Host.

TextTransform.exe is located in the following directory:

::: moniker range="=vs-2019"

\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE

for Professional edition, or

\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE

for Enterprise edition.

::: moniker-end

::: moniker range=">vs-2019"

\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE

for Professional edition, or

\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE

for Enterprise edition.

::: moniker-end

Syntax

TextTransform [<options>] <templateName>

Parameters

Argument Description
templateName Identifies the name of the template file that you want to transform.
Option Description
-out <filename> The file to which the output of the transform is written.
-r <assembly> An assembly used for compiling and running the text template.
-u <namespace> A namespace that is used for compiling the template.
-I <includedirectory> A directory that contains the text templates included in the specified text template.
-P <referencepath> A directory to search for assemblies specified within the text template or for using the -r option.

For example, to include assemblies used for the Visual Studio API, use

-P "%VSSHELLFOLDER%\Common7\IDE\PublicAssemblies"
-dp <processorName>!<className>!<assemblyName|codeBase> The name, full type name, and assembly of a directive processor that can be used to process custom directives within the text template.
-a [processorName]![directiveName]!<parameterName>!<parameterValue> Specify a parameter value for a directive processor. If you specify just the parameter name and value, the parameter will be available to all directive processors. If you specify a directive processor, the parameter is available only to the specified processor. If you specify a directive name, the parameter is available only when the specified directive is being processed.

To access the parameter values from a directive processor or text template, use ITextTemplatingEngineHost.ResolveParameterValue. In a text template, include hostspecific in the template directive and invoke the message on this.Host. For example:

<#@template language="c#" hostspecific="true"#> [<#= this.Host.ResolveParameterValue("", "", "parameterName") #>].

Always type the '!' marks, even if you omit the optional processor and directive names. For example:

-a !!param!value
-h Provides help.

Related content