We’re happy to announce that Visual Studio 2022 v17.6 now includes an updated Text Template Transformation Toolkit (T4) command-line tool built with .NET 6.
For those unfamiliar, T4 is a powerful framework that allows you to automate the creation of text files. It’s perfect for automating the creation of HTML, XAML, or even code models from REST APIs. These template files can contain invokable .NET code and string literals, so it’s critical that our users are able to utilize the latest .NET 6+ features and libraries.
Try It
Using the new TextTransformCore.exe
utility is simple: all arguments are the same as TextTransform.exe
. The location of the new utility is also the same and can be found under {VS_INSTALL_PATH}\Common7\IDE\TextTransformCore.exe
.
Feedback
We want to hear from you! Please file feedback or issues in our Developer Community.
Additionally, there are a few questions we have about how best to support our T4 users who wish to use .NET (Core) libraries, so we’ve prepared a short survey.
Limitations
We currently do not yet support in-IDE or MSBuild task file generators for .NET 6+. However, if your template does not rely on invoking in-IDE services you can work around this by using the new TextTransformCore.exe
with the Exec
command.
Here’s an example, as a PreBuild step:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="'$(DevEnvDir)TextTransformCore.exe' '$(ProjectDir)MyFile.tt'" />
</Target>
Known issues
There’s currently a known issue where transforms will fail when setting the attribute hostSpecific
to true. If you do not use this.Host
we recommend that you set the attribute hostSpecific="false"
. This issue only applies to TextTransformCore.exe
.
Thanks for your patience — we’re excited to see how you utilize these new T4 capabilities.
The post Introducing the New T4 Command-Line Tool for .NET appeared first on .NET Blog.
Comments
Post a Comment