I was writing a quick T4 template in Visual Studio 2008 in a VB.NET project and noticed a few quirks/differences when compared to a C# project.
When you add a text file named “Test.tt” in a C# project, Visual Studio processes the T4 template and generates a corresponding “Test.cs” file:
I expected similar behavior in VB.NET, but I was quite disappointed. For starters, I didn’t see any apparent output. To fix this little issue, I had to click on the “Show All Files” button on the Solution Explorer. Then the file showed up, but I was even more confused because I saw this:
Apparently, the default file extension for T4 templates is “.cs”, so this shouldn’t have really surprised me, but I found it odd that in my VB project, I would have a C# file. Fortunately, the fix is quite simple: add an output processor directive to the T4 file so that the file extension is “.vb”:
<#@ output extension=".vb" #>
That’s it. I hope this post saves a poor soul some time.