如何依赖添加到任意文件到T4模板? [英] How to add a dependency to a arbitrary file to a T4 template?

查看:156
本文介绍了如何依赖添加到任意文件到T4模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生成的类从XML文件T4模板。

I have a T4 template that generates classes from an xml file.

我如何添加xml文件和模板文件之间的依赖关系,当XML文件被修改的模板会自动重新运行,而不从上下文菜单中选择运行自定义工具?

How can I add a dependency between the xml file and the template file so that when the xml file is modified the template is rerun automatically without choosing "Run custom tool" from the context menu?

推荐答案

我不相信T4支持基于外部的依赖自动模板转换。我同意马克 - 如果你只有一个外部文件,你可以为你的XML文件中创建一个自定义的自定义工具,或简单地使用的 ttxgen 。但是,我不认为这种做法扩展到这样一个场景,T4模板依赖于多个文件。您可能需要创建一个Visual Studio包来处理的。

I don't believe T4 supports automatic template transformation based on an external dependency. I agree with Marc - if you only have one external file, you could create a custom "custom tool" for your XML file or simply use ttxgen. However, I don't think this approach scales up to a scenario where t4 template depends on more than one file. You may need to create a Visual Studio package to handle that.

这篇关于如何依赖添加到任意文件到T4模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆