ASP.Net T4MVC 文件未自行更新
我正在使用 T4MVC
模板在 ASP.Net MVC (.Net 4.0) 中工作。
到目前为止,每当我向项目中添加新文件(如控制器、视图等)时,该文件都会自动更新条目。
但由于某种原因,它已经停止自我更新。我刚刚在项目中添加了新文件夹,其中包含 3 个 aspx
文件以及相关的控制器和模型。但 T4MVC 仍然根本不显示这些内容,并且编译器会因缺少内容而给出错误。
有人可以帮我找出原因吗?
谢谢!
I am wokring in ASP.Net MVC (.Net 4.0) with T4MVC
template.
So far this file was getting updated with entries automatically whenever I used to add new files into my project (like controllers, views, etc.).
But for some reason, it has stopped updating itself. I have just added new folder into project with 3 aspx
files and also related controllers and models. But still T4MVC does not show these things at all and the compiler gives errors for missing things.
Can anybody please help me figuring out the reason?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
T4MVC 不会自行更新。
您必须右键单击解决方案资源管理器中的
.tt
文件,然后单击运行自定义工具。当您这样做时,您的解决方案也将编译。
T4MVC 将所有控制器方法更改为虚拟并为它们写入覆盖。因此,当您编译时,T4MVC 会出现编译错误,这可能是因为您重命名或更改了控制器中方法的签名。从 T4MVC 中删除此方法,然后单击运行自定义工具重新生成。
有关 T4MVC 的详细信息,请参阅此答案:
ASP.NET MVC3 如何引用视图直接来自控制器
T4MVC will not update itself.
You have to Right-Click the
.tt
files in your solution explorer and click Run Custom Tool.When you do this, your solution will also compile.
T4MVC changes all your controller methods to virtual and writes overrides for them. So when you compile sometime, T4MVC will have a compile error, thats probably because you renamed or changed the signature of a method in your controller. Delete this method off from T4MVC and click Run Custom Tool to regenerate.
See this answer for details on T4MVC:
ASP.NET MVC3 How to reference views directly from controller
AutoT4MVC 是一个不错的轻量级选项,可以自动运行自定义工具。
不过它只支持 T4MVC,因此如果您将 Chirpy 用于其他用途,那么它可能值得保留。
AutoT4MVC is a nice little light weight option that does the auto-running of the custom tool.
It only does T4MVC though so if you use Chirpy for other stuff it may be worth keeping.
如果您想自动运行 t4mvc,请查看此 Visual Studio pugin http://chirpy.codeplex.com/ 。它还具有非常好的其他功能。
If you want to autorun t4mvc check-out this Visual Studio pugin http://chirpy.codeplex.com/ . It has also very nice other features.