Instruct T4 to use C# v3.5

Consider this simple T4 template:

<# for (var i = 0; i < 10; ++i) { WriteLine("hello"); } #>

Trying to build the project results in a compilation error because ‘var’ is an unknown type. A bit of research learned me that i should instruct the processor to use a specific c# version like this:

<#@ template language="C#v3.5" inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation"  #>
<# for (var i = 0; i < 10; ++i) { WriteLine("hello"); } #>

Problem solved :)

This entry was posted on Friday, September 11th, 2009 at 09:05 and is filed under C#, Visual Basic. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply