剃须刀的观点没有给编译时错误 [英] razor views are not giving compile time error
问题描述
我最近安装了VS 2012专业版。
当我尝试建立我的MVC4 Web项目。它不承认错误的Razor视图,当我做生成或重新构建。
示例:
我删除命名空间从项目/或者说重新命名。我构建解决方案,它给我的错误在所有的CS文件,这是我固定通过改变名称空间。整个解决方案成功打造。当我运行它给我的编译错误的项目话说,命名空间没有找到,因为旧的命名空间是在一些看法(* .cshtml文件)仍称。
预期的解决方案:
我希望当我这样做生成或重新生成,应该承认这种错误,并告诉我与任何其他错误一起。
这是工作的罚款VS 2010中,我失去了任何配置?
在此先感谢!
阿米特
修改
我找到自己的答案,我认为这是年初发布问题:
<一个href=\"http://stackoverflow.com/questions/5014317/razor-syntax-with-errors-compiles-when-it-should-not-compile\">razor语法有错误时,编译它不应该编译
另一个问题
在.csproject文件中更改值设置为True,当我开始建设后,
该项目它显示错误,但只显示一个错误的时间。
比方说,我在总共3次5个错误。它只是表明我一个
错误。是否有任何解决方案,以便它显示了所有的5个错误?
块引用>解决方案
当我尝试建立我的MVC4 Web项目。它不承认错误
剃刀视图,当我做生成或重新构建。
块引用>似乎正常。剃刀视图由ASP.NET运行时动态编译。如果你希望你的意见,在编译时建立可以将以下选项添加到您的
.csproj的
文件:&LT;&的PropertyGroup GT;
&LT; MvcBuildViews&GT;真&LT; / MvcBuildViews&GT;
&LT; /&的PropertyGroup GT;I've recently installed VS 2012 Professional.
When i try to build my MVC4 Web Project. It doesn't recognize error in razor view when i do "Build" or "Re-Build".
Example :
I removed a namespace from the project / or say renamed it. i build the solution, it gave me errors in all cs files, which i fixed by changing the namespace. The entire solution build successfully. When i run the project it gave me Compilation Error saying that namespace not found, because the old namespace was still referred in some of the views (*.cshtml files).Expected Solution :
I wish when i do "Build" or "Re-Build", it should recognize such errors and show me along with any other errors.This was working fine with VS 2010, am i missing any configuration?
Thanks In Advance !! Amit
Edit I found the answer myself, i think it was early to post the question :
razor syntax with errors compiles when it should not compile
Another Problem
After changing value to True in .csproject file, when i start building the project it shows error, but it shows only one error at a time. let's say, i've 5 errors in total 3 views. it would just show me one error. Is there any solution so that it shows all the 5 errors ?
解决方案When i try to build my MVC4 Web Project. It doesn't recognize error in razor view when i do "Build" or "Re-Build".
Seems normal. Razor views are dynamically compiled by the ASP.NET runtime. If you want your views to be built at compile-time you could add the following option to your
.csproj
file:<PropertyGroup> <MvcBuildViews>true</MvcBuildViews> </PropertyGroup>
You may take a look at the this article for more details.
这篇关于剃须刀的观点没有给编译时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!