相关疑难解决方法(0)

在ASP.NET MVC中编译视图

我想要一个msbuild任务来编译视图,这样我就可以看到编译时是否存在编译错误...编译时.有任何想法吗?

asp.net msbuild asp.net-mvc

545
推荐指数
7
解决办法
10万
查看次数

MVCBuildViews无法正常工作

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

<MvcBuildViews>true</MvcBuildViews>
Run Code Online (Sandbox Code Playgroud)

这应该导致我的视​​图在构建期间被编译,并在我的视图被破坏时强制构建错误.这是我做的唯一更改,但是,当我尝试构建应用程序时,出现以下错误:

在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的.此错误可能是由于未在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>
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么吗?如何正确配置MVC 3/Visual Studio 2010以在构建时验证我的视图?

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

49
推荐指数
4
解决办法
3万
查看次数

标签 统计

asp.net-mvc ×2

msbuild ×2

asp.net ×1

c# ×1

visual-studio-2010 ×1