本文介绍了每个模板T4模板TransformOnBuild设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
构建项目时,我想自动执行一个.tt文件,而不执行其他文件。是否可以在特定的.tt文件而不是项目范围内设置TransformOnBuild属性?还是另一种实现此目的的方法?
I would like to automatically execute one of the .tt files when my project is built, but not the others. Is it possible to set the TransformOnBuild property on specific .tt files instead of project wide? Or another method to accomplish this?
推荐答案
我决定添加一个自定义的预构建步骤来生成所需的.tt文件:
I have decided to add a custom pre build step to generate the .tt files needed:
<Exec Command=""%PROGRAMFILES(x86)%\Common Files\microsoft shared\TextTemplating\10.0\TextTransform.exe" template.tt -out template.cs" />
此方法还允许我使用-轻松将参数(在项目文件中定义)传递给模板。一种;我面临的另一个问题。
This method also allowed me to easily pass parameters (defined in the project file) to the template with -a; another problem I was facing.
这篇关于每个模板T4模板TransformOnBuild设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!