Executing a T4 text template in Visual Studio Code
Asked Answered
L

2

16

I created a T4 text template (.tt) file in Visual Studio Code, but unlike Visual Studio 2017 (or 2015 ,...) it won't generate the output file after saving the .tt file. How can I generate the output in Visual Studio Code?

Lamm answered 7/3, 2018 at 9:16 Comment(3)
I'm using Visual Studio Code(VsCode) not VS2017.Lamm
any luck on this?Unnerve
Try this extension: marketplace.visualstudio.com/…Burnight
U
7

This solution is not exactly what you asked, but it may be useful in many scenarios (on Windows OS only).

You can create a task in Visual Studio Code and run C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\TextTransform.exe. If you don't have Visual Studio you can copy this file to your project folder and execute it from that location.

Any extension that can run a .exe file can do the job.

User answered 3/9, 2018 at 19:44 Comment(0)
E
0

If you so desire (depends on how much you want it!) it looks like you could create your own app based upon the classes Microsoft uses for TextTransform.exe, Microsoft has written a walkthrough of how to do it:

Walkthrough: Create a Custom Text Template Host

If you want to perform text transformation as part of a build process, consider using the MSBuild text transformation task. For more information, see Code Generation in a Build Process. In a machine on which Visual Studio is installed, you can also write an application or Visual Studio Extension that can transform text templates. For more information, see Processing Text Templates by using a Custom Host.

I'm not sure however if the assemblies it mentions

Microsoft.VisualStudio.TextTemplating.*.0

Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 and later versions

are .NET standard / .NET Core, i.e. if they are cross platform.

Enclasp answered 24/1, 2019 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.