0

有没有办法从 T4 模板创建 dll 并从此 dll 生成代码?现在我需要通过硬编码设置参数,当你保存时(按Ctrl + S),模板开始生成,但必须有一个很好的可重用方式。有人有什么建议吗?

更新

我需要一个包含 T4 模板的库应用程序,我可以从任何引用此库的应用程序传递参数并获取生成的代码作为返回。但我不知道如何从 T4 创建一个 dll

4

1 回答 1

2

What you want is Runtime (also called Preprocessed) templates. With these you'll generate the template code rather than the template output. You can then embed that code in any part of your app with no runtime dependencies on T4.

MSDN docs: http://msdn.microsoft.com/en-us/library/ee844259.aspx

Oleg Sych's blog on the subject: http://www.olegsych.com/2009/09/t4-preprocessed-text-templates

于 2012-08-07T18:41:22.507 回答