asp.net mvc4 设置build项目时,编译view页面

新建好项目后,把system.web.mvc.dll移除,重新选择本地C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies下的system.web.mvc.dll,编译出现问题提示:“The type or namespace name 'Html' does not exist in the namespace 'System.Web.Mvc'”

切换回来对应新建时应用目录下的system.web.mvc.dll依然出现问题。

让view重新编译:

1,)修改web解决方案.csproj文件,

1.1,)设置MvcBuildViews属性为true;

<MvcBuildViews>true</MvcBuildViews> 

1.2,)在</Project>前面加上以下内容:

 1     <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
 2        Other similar extension points exist, see Microsoft.Common.targets.
 3   <Target Name="BeforeBuild">
 4   </Target>
 5   <Target Name="AfterBuild">
 6   </Target> -->
 7   <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
 8     <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
 9   </Target>
10 </Project>

,之后重新编译,问题就解决了。

posted @ 2015-11-25 00:16  cctext  阅读(737)  评论(0编辑  收藏  举报