Can C ++ projects use T4 in Visual Studio 2010?

T4 did not work for C ++ projects in Visual Studio 2008, because it did not use msbuild for C ++ projects. (Yes, there were workarounds). In Visual Studio 2010, C ++ projects use MsBuild, so does anyone know if C ++ projects can use T4 in the same way as C # or VB?

+4
source share
2 answers

The primary mechanism for integrating T4 in C # and Visual Basic projects is the custom TextTemplatingFileGenerator tool. Although projects in Visual Studio 2010 C ++ now use MSBuild, they still do not support special tools. As a workaround, you can use the T4 Toolbox , which allows you to put the .tt file in a C # or Visual Basic project and have the files it automatically generates your C ++ project.

+3
source

I was interested in finding a way to use C ++ using T4 Templating, and in the end I just used the command line and the TextTransform.exe tool. You can then write a batch file that will call TextTransform.exe for all of your individual template.tt files, and then just call the batch file as part of your assembly in visual studio.

Since I studied this, I decided to write my findings in a tutorial, which can be found here ... http://www.gamelogicdesign.com/2012/04/12/c-code-generation-using-t4-templates/

Perhaps this will be useful for people who would like to do something like this.

+2
source

Source: https://habr.com/ru/post/1302894/


All Articles