How to run a T4 template from a PowerShell script

In my VS2010 solution, I have a set of Powershell scripts and T4 templates based on T4Scaffolding NuGet, everything works fine with the stage and associated T4, but in one of my scripts I need to run the T4 template located in another project.

Any simple Powershel cmdlet for this? just run the template without any parameters or values.

Thanks.

+7
source share
1 answer

It looks like you can just call your command line utility so that you can create a script that just takes up the location of your .tt file.

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

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

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

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

+11
source

All Articles