Friday, December 12, 2008

AppVenture Launches Stand-Alone T4 Template Engine

We at AppVenture have built a stand-alone T4 Engine to process and test T4 templates as part of a continuous integration environment.  We hope the community finds it useful.  Licensing is yet to be determined, but we plan to use a BSD-style license to keep everyone’s options open.

Get the AppVenture T4 Template Engine.

 |  Fernando Cardenas  |  #    |  Comments [4]  | 
 Thursday, November 06, 2008

T4 Strangeness in VB.NET and Visual Studio 2008

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:

Test.tt

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:

Test.tt.vb

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.

 |  Fernando Cardenas  |  #    |  Comments [4]  |