How not to output default T4 generated file?

2019-02-11 10:52发布

I am using T4toolbox to generate a bunch of files, let's say my t4 file name is x.t4, but default it generate a x.txt, which has nothing inside, can I tell t4 engine not to do this?

标签: t4
3条回答
beautiful°
2楼-- · 2019-02-11 11:41

Found a trick/hack!

<#@ output extension="/" #>

or

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

Visual Studio 2012 neither outputs the default file, nor complains about its inability too much.

P.S. I've tried it with T4MultiFile NuGet package, but it should work with T4Toolbox too, I think.

查看更多
男人必须洒脱
3楼-- · 2019-02-11 11:53

Right click on x.t4 in Solution Explorer and click Properties. It will say "TextTemplatingFileGenerator" beside Custom Tool. Delete this.

x.t4 will now be part of your project but it will not generate anything. This is useful when the .t4/.tt file is only being used as an include file in other templates.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-02-11 11:57

No. This file is created by Visual Studio and not by T4. The best you can do is generate something useful in it such as actual code or, perhaps, a log of the code generation run.

查看更多
登录 后发表回答