Can I use T4 to write raw bytes into the output?
See the question and my original answer on StackOverflowI don't think it's possible with T4, but you could write your own custom VS file generator without too much effort, see here: Writing a custom tool to generate code for Visual Studio .NET