Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 Disable T4 Template Validation

How do you disable T4 Template validation . VS2010 is validating my T4 Template just now on ever part that has '#' (the sharp character).

error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line

The error is nonsense. I can even generate code from my templates but I can't run my project because my templates throw error CS1040.

I get this error after installing visual t4, even uninstalling from extensions manager won't work. Installing Visual T4 for VS2010 gave me problems with subsonic templates. disabling and uninstalling didn't help either. I am so disappointed.

like image 765
Aivan Monceller Avatar asked Dec 22 '10 14:12

Aivan Monceller


2 Answers

The build action of your T4 template has changed. This may happen when you have copied your files from one project to another, or changed it in the properties by accident.

Steps to resolve it:

  • Right-click the file and choose Properties (Alt+Enter).
  • Select Build Action and change it to the default value None.
  • Save the project and rebuild.
like image 67
MovGP0 Avatar answered Nov 13 '22 19:11

MovGP0


For some reasons "Build Action" for T4 templates changed to 'compile' just set it back to 'content'

like image 39
Aivan Monceller Avatar answered Nov 13 '22 18:11

Aivan Monceller