How to trigger T4 template from PowerShell script

别来无恙 提交于 2019-12-04 19:37:35

问题


In my VS2010 solution I have set of Powershell scripts and T4 templates based on T4Scaffolding NuGet, everything is working fine with scaffolding and related T4's, but in one of my scripts I need to trigger a T4 template located in another project.

Any simple Powershel cmdlet for this? to just run the template with out passing any parameters or values.

Thanks.


回答1:


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

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.



来源:https://stackoverflow.com/questions/9217120/how-to-trigger-t4-template-from-powershell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!