MVCBuildViews 无法正常工作 [英] MVCBuildViews not working correctly
问题描述
所以我在 MVC 3 RTM 应用程序上编辑了我的 csproj 文件以设置以下属性:
So I edited my csproj file on an MVC 3 RTM application to set the following property:
<MvcBuildViews>true</MvcBuildViews>
这应该会导致我的视图在构建期间得到遵守,如果我的视图被破坏,则会强制构建错误.这是我所做的唯一更改,但是,当我尝试构建应用程序时,出现以下错误:
This should cause my views to be complied during build and force a build error if my view is broken. This is the only change I made, however, when I try to build the application, I get the following error:
在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的部分是错误的.此错误可能是由于虚拟目录未在 IIS 中配置为应用程序所致.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
如果我改回false,项目编译运行成功,
The project compiles and runs successfully if I change back to false,
以下是csproj文件中配置的构建任务(这些从来没有手动编辑过,它们是由Visual Studio 2010添加的)
The following are the build tasks configured in the csproj file (these were never manually edited, they were added by Visual Studio 2010)
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target> -->
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
我在这里遗漏了什么吗?如何正确配置 MVC 3/Visual Studio 2010 以在构建时验证我的视图?
Am I missing something here? How do I get MVC 3 / Visual Studio 2010 configured correctly to validate my views at build time?
推荐答案
几天前我遇到了这个问题,我通过删除 obj/Debug 文件夹修复了它.清理项目也有效.不过,我不知道问题的原因.
I had this problem a few days ago and I fixed it by deleting obj/Debug folder. Cleaning the project also works. I have no idea about the cause of the issue, though.
请参阅 Joe Cartano 的回答以获得更持久的解决方案.
See Joe Cartano's answer for a more permanent solution.
这篇关于MVCBuildViews 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!