每个模板 TransformOnBuild 设置的 t4 模板

发布于 2024-12-22 11:15:36 字数 99 浏览 1 评论 0原文

我想在构建项目时自动执行其中一个 .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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情话已封尘 2024-12-29 11:15:36

我决定添加自定义预构建步骤来生成所需的 .tt 文件:

<Exec Command=""%PROGRAMFILES(x86)%\Common Files\microsoft shared\TextTemplating\10.0\TextTransform.exe" template.tt -out template.cs" />

此方法还允许我使用 -a 轻松地将参数(在项目文件中定义)传递到模板;我面临的另一个问题。

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.

仙女 2024-12-29 11:15:36

回答作为实现此目的的另一种方法。

  1. 您可以将 .tt 更改为 TextTemplatedFilePreprocessor
    (这里描述得更好:
    http://www.olegsych.com/2009/09/t4-预处理文本模板/)。
  2. 创建在预构建事件上执行预处理器的小型命令行工具。

第一个链接包含此示例,但它描述了预处理类的使用:
http://blogs.clariusconsulting.net/pga/ vs10-beta-1-t4-preprocessing-part-2/

Answering as another method to accomplish this.

  1. You could change your .tt as TextTemplatingFilePreprocessor
    (descibed better here:
    http://www.olegsych.com/2009/09/t4-preprocessed-text-templates/).
  2. Create small command line tool that executes the preprocessor on pre-build event.

The first link includes this example, but it describes the use of preprocessed class:
http://blogs.clariusconsulting.net/pga/vs10-beta-1-t4-preprocessing-part-2/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文