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

前端 未结 3 1955
轻奢々
轻奢々 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:32

    ADDENDUM - ASP.NET MVC 3 RTM

    As an addendum to this issue, if you have just installed ASP.NET MVC 3 RTM, you may hit similar problems in projects that were created using one of the MVC 3 Release Candidates.

    To solve:

    Make sure that you have T4MVC.2.6.40 or later installed using NuGet.

    Ie, reinstall T4MVC using Tools >> Library Package Manage. In the Console, type:

    uninstall-package t4mvc 
    

    and then:

    install-package t4mvc 
    

    to get the latest version.

    You will now probably get the following error in the T4MVC.tt file:

    A namespace cannot directly contain members such as fields or methods
    

    Open the file, make it dirty (eg, by deleting the comment with the squiggly line) then close WITHOUT SAVING!!! See David Ebbo's answer, t4mvc.tt NEEDS to be dirty!

    Recompile and go get a life.

提交回复
热议问题