c# - MVCBuildViews 无法正常工作

标签 c# asp.net-mvc visual-studio-2010 msbuild

所以我在 MVC 3 RTM 应用程序上编辑了我的 csproj 文件以设置以下属性:

<MvcBuildViews>true</MvcBuildViews>

这应该会导致我的视​​图在构建期间得到遵守,并在我的 View 被破坏时强制出现构建错误。这是我所做的唯一更改,但是,当我尝试构建应用程序时,出现以下错误:

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,项目编译运行成功,

以下是在csproj文件中配置的构建任务(这些从来没有手动编辑过,它们是由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 以在构建时验证我的 View ?

最佳答案

几天前我遇到了这个问题,我通过删除 obj/Debug 文件夹修复了它。清理项目也有效。不过,我不知道问题的原因。

参见 Joe Cartano's answer以获得更永久的解决方案。

关于c# - MVCBuildViews 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4725387/

相关文章:

asp.net-mvc - 域模型命名空间命名约定

vb.net - 算术运算导致溢出

C++ map 比较

c# - 一个 XmlDataProvider WPF 的多个 XPath

c# - WPF 控件库目标 .NET Core 3 或 .NET Framework?

c# - 通用 Windows 平台中的 System.Xml.XPath

mysql - ASP.NET MVC Razor,使用 url/profile/{username} 生成配置文件

c# - C# 中奇怪的 BinaryFormatter 反序列化错误

asp.net-mvc - 如何在Site.Master页面上检查当前用户角色?

visual-studio-2010 - VS 2010 调试器在附加到 NUnit 时不加载符号