How to indicate whether a T4 file should produce any output

I use T4 to generate some DTO + mappers classes.

I split the files in a few rewritable bits (some of which contain common methods, some other common procedures) and include them in the T4 templates that will give my output - this is all good.

My problem is that reusable .tt files will try to create their own output and fail (because they are associated with some other .tt files) every time I make them changes, that just sucks.

I am sure that I saw somewhere some directive to indicate this file, you should not try to produce any output, but I can not track it.

Any help appreciated!

+3
source share
4 answers

In the properties (select the file and press F4) of the T4 files for which you want to disable output, clear the "Custom tool" entry.

+4
source

You can specify an invalid extension to suppress the output of your template, for example:

<#@ output extension="\n" #>
+7
source

"StackOverflow street cred", , . .

: T4 (, Tangible T4), , .

< # @output extension = "\n" # >

So, I found setting the extension to something that is not an escape char as follows:

<# @output extension = "" #>

and then in the code section programmatically set the file extension, for example:

Host.SetFileExtension ("\ n");

The T4 backlight is then restored.

+4
source

rename them to .ttinclude and see how this happens for ya ....

+1
source

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


All Articles