且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从PowerShell脚本触发T4模板

更新时间:2023-12-02 21:26:04

您似乎可以调用它们的命令行实用工具,因此可以创建一个仅包含.tt文件位置的脚本。

It looks like you can just invoke their command line utility, so you could create a script that just takes the location of your .tt file.

param([string] $T4Template)

& "C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\10.0\TextTransform.exe" $T4Template

另存为ExecTextTransform.ps1,然后使用您的路径进行调用。
示例:

Save above as ExecTextTransform.ps1 and then call with your paths. Example:

.\ExecTextTransform.ps1 c:\temp\example.tt

请参见此处,以示例调用其命令行实用程序。

See here for an example of calling their command line utility.