有没有办法将 T4 指令放在注释括号内?

Is there a way I can put T4 directives inside comment brackets?

考虑以下代码:

<#@ assembly name="$(Path)\Custom.dll" #>
<#@ assembly name="$(OtherPath)\Custom.dll" #>

我想做一些类似的事情:

<#@ assembly name="$(Path)\Custom.dll" #>
<!--<#@ assembly name="$(OtherPath)\Custom.dll" #>-->

是否有允许我在注释中放置指令的语法?

我不这么认为,因为 T4 在编译文件时使用正则表达式从文件中解析出代码和指令。它使用的正则表达式语句正在搜索 <#@ 和 #> 行,并将其他所有内容视为模板的一部分。