See this thread
If can add t4 templates as a build step in a .net core project, but the step is only called on build, not run
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
After some testing, it looks like the TextTemplating library that is part of VisualStudio (Microsoft.VisualStudio.TextTemplating.15.0.dll) can't be used in the newer "dotnet" command line toolchain as it depends on the WPF assembly WindowsBase.dll. This causes the .tt code generation to fail, even on a Windows machine.
After some investigation, we found some open-source projects that are able to do .tt code generation, most notably mono/t4, but these solutions have the disadvantage of not being so well integrated with VisualStudio as the current TextTemplating is. For example, it's harder (if not impossible) to get design-time generation and we also lose the ability to trigger the code generation from the context menu in the solution explorer.
Given these drawbacks, I'd just like to know what is Microsoft's position on this. Is there a plan to update the existing TextTemplating libraries so that they are compatible with the "dotnet" toolchain while still maintaining good integration within the VS IDE? Or is TextTemplating being left behind and we must rely on the not-so-well-integrated open-source solutions?
See this thread
If can add t4 templates as a build step in a .net core project, but the step is only called on build, not run
Obviously, a lot of people ran into these incompatibility issues and started their own ports of T4 tooling, as a quick search on GitHub demonstrates. This is a pity, since with every variation of the toolchain we seem to be losing a feature rather than the opposite... I vote for Microsoft taking over again and providing a cross platform Visual Studio independent solution, which does work in Visual studio, including debugging and Intellisense support.
I have set up a "universal" tooling which works in Visual Studio and as a command line tool on all supported platforms but it was a lot of work and unnecessary frustration.
In the mean time Microsoft seems to at least addresed this problem to some extent with the creation of TextTranformCore.exe
as per https://devblogs.microsoft.com/dotnet/t4-command-line-tool-for-dotnet/.
They even suggest a PreBuild step based solution for build time generation (with some limitations though)
I have never had any issues with text templating and is still supported.
Seems Microsoft is pushing source generators over text templating.
Example for text templating using NET8.
Also, see T4 language extension for syntax coloring.