Cannot get T4MVC to work with VS2010 and ASP.NET MVC 2

前端 未结 3 1943
轻奢々
轻奢々 2020-12-18 00:07

I\'m trying to add the T4MVC templates to my project, but I\'m experiencing some problems. I went to Codeplex and downloaded the latest version of T4MVC, and according to th

3条回答
  •  抹茶落季
    2020-12-18 00:29

    OK, I figured it out. The problem was that apparently since the last release of the T4MVC package, Microsoft changed the location of the ITextTemplateHost interface, so I needed to import another namespace. Also, the .dll files with these namespaces aren't imported in the default ASP.NET MVC template project. This is what I did to make it work:

    1. Add references to the following .dll files (search paths on my machine in brackets):

      • Microsoft.VisualStudio.TextTemplating.10.0.dll (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.10.0\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.10.0.dll)

      • Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

    2. Make sure the following namespaces are both imported in T4MVC.tt (just follow the syntax that's already in the file).

      • Microsoft.VisualStudio.TextTemplating

      • Microsoft.VisualStudio.TextTemplating.Interfaces

    3. Delete all generated code files (they'll appear if you expand the T4MVC.tt in Solution Explorer).

    4. Build project. If no files are generated, open T4MVC.tt, edit something, don't save and build. That should do it!

提交回复
热议问题