Running T4 templates from other T4 template

后端 未结 4 1481
攒了一身酷
攒了一身酷 2020-12-31 12:41

does anyone know if it\'s possible to run T4 template file from another T4 template, inside VS2010

Thank

4条回答
  •  不知归路
    2020-12-31 13:23

    Yes, you can. This is how I'm doing it:

    string templateText = File.ReadAllText(Host.ResolvePath(templateFileName));
    Engine engine = new Engine();
    string output = engine.ProcessTemplate(templateText, Host);
    //this is optional - record all output to your file of choice:
    File.WriteAllText(outputFilePath, output); 
    

提交回复
热议问题