17

I'm trying to use the T4 templates in my MVC project. This screencast suggests just copying the existing T4 templates for MVC into your solution and going from there. However when I try to compile I get this error:

Error   1   Compiling transformation: The type or namespace name   
'MvcTextTemplateHost' could not be found (are you missing a using directive
or an assembly reference?)  

I have no idea what assembly this might live in, and google isn't being much help with it. Does anyone know what assembly I should reference?

Kirschstein
  • 14,570
  • 14
  • 61
  • 79

2 Answers2

26

For each template right click, select Properties and clear the Custom Tool property. This has worked for my projects.

  • 1
    Here's and MSDN blog link with the same advice: http://blogs.msdn.com/webdevtools/archive/2009/01/29/t4-templates-a-quick-start-guide-for-asp-net-mvc-developers.aspx – Kevin Hakanson Nov 22 '09 at 19:21
  • It's blank in mine as well. I got this after installing MVC SPA and the MVC SPA C# update. – vealer Jan 04 '13 at 17:40
  • 3
    If the .tt files causing this error came from a Nuget package install, closing Visual Studio and reopening it will solve it. If the .tt files came from somewhere else, like you copying and adding them in, or writing your own, deleting the text in Custom Tool will usually do the trick. – Chris Moschini Apr 18 '13 at 00:23
8

I got this error after installing twitter bootstrap via console

Install-Package twitter.bootstrap.mvc4.sample

and my solution was to close visual studio and re-open it, and the error was gone.

sawe
  • 1,141
  • 14
  • 24
  • 2
    Yeah, interesting. This was the answer for me as well: closing and re-opening Visual Studio 2010. – vealer Jan 04 '13 at 17:46