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?
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.
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.
© 2022 - 2024 — McMap. All rights reserved.