I am using T4 for generation of some DTO classes + mappers.
I am splitting the files in a number of re-usable bits (some of which containing common methods, some others common procedures) and including them into the T4 templates that开发者_运维知识库 will produce my output - which is all good.
My problem is that the re-usable .tt files will try and produce their own output and fail (because they are coupled to some other .tt files) every time I make a change to them, which plain sucks.
I am pretty sure I saw somewhere some directive to specify a given file shouldn't try and produce any output, but I can't seem to track it back.
Any help appreciated!
You can specify invalid extension to suppress the output of your template, for example:
<#@ output extension="\n" #>
In the properties (select file and press F4) of the T4 files for which you'd like to suppress output, clear the 'Custom Tool' entry.
I don't have enough 'StackOverflow street cred' to reply to Stanislav Kniazev's answer, so will have to post my own here. Thanks for the lead Stanislav Kniazev.
The following worked; but if you are using a T4 syntax highlighter (like Tangible T4) you will find that it stuffs up the highlighting.
<#@ output extension="\n" #>
So I found setting the extension to something that is not an escape char like this:
<#@ output extension="" #>
and then in the code section programmatically setting the file extension, like this:
Host.SetFileExtension("\n");
T4 highlighting is then restored.
rename them to .ttinclude and see how that goes for ya....
精彩评论