T4 templates - avoid empty lines from included files
To add to Tony's answer: You can avoid the very long lines by adding the linebreaks within the T4 brackets like so:
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".ttinclude" #>
<#@ Import Namespace="System.Collections.Generic" #>
<#@ Include file="Usings.tt"
#><#@ Include file="PropertyTypeEnum.tt"
#><#@ Include....
#><#@ Include....
#><#@ Include....
#><#@ some other stuff
Oh well, the solution turned out to be trivial, if somewhat unexpected : just put the include directives next to each other, instead of one below another :
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".ttinclude" #>
<#@ Import Namespace="System.Collections.Generic" #>
<#@ Include file="Usings.tt" #> <#@ Include file="PropertyTypeEnum.tt" #> <#@ Include....
I had a more fundamental issue where each <#@
header line before <?xml
caused its own blank line in the output, which caused the error:
error : Unexpected XML declaration.
The XML declaration must be the first node in the document,
and no white space characters are allowed to appear before it.
Line 7, position 3.
After digging for a while I discovered the .tt file had Unix EOL.
When I switched to Windows EOL, the transform removed the blank lines.