Hier finden Sie folgende Anweisungen http://www.olegsych.com/2008/03/how-to-generate-multiple-outputs-from-single-t4-template/
Ich habe versucht, var personName von test1.tt an template1.tt zu übergeben, aber ich kann keine Datei sehen, warum?
Vorlage1.tt
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".txt" #>
<#@ assembly name="System"#>
hello <#= personName #>
test1.tt
<#@ template language="C#" hostspecific="True" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="Microsoft.VisualStudio.TextTemplating" #>
<#@ import namespace="System.Runtime.Remoting.Messaging" #>
CallContext.SetData("template1.personName", "Baby");
ProcessTemplate("template1.tt","testoutput.txt");
<#+
void ProcessTemplate(string templateFileName, string outputFileName) {
string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
string outputFilePath = Path.Combine(templateDirectory, outputFileName);
string template = File.ReadAllText(Host.ResolvePath(templateFileName));
Engine engine = new Engine();
string output = engine.ProcessTemplate(template, Host);
File.WriteAllText(outputFilePath, output);
}
#>