ASP.net Web Forms, get aspx/view errors at compile time?

好久不见. 提交于 2019-12-18 13:01:29

问题


I know this can be done with mvc2, but is there any way for visual studio(2010)/resharper(6) to check for errors on aspx pages at compile time and halt the build? Resharper can detect the errors just fine, so it seems like there should be a way to integrate a check of all the aspx pages in to the build process.

Any tips?


回答1:


Yes you can. The following steps will cause .aspx files to be compiled as part of a normal builk invoked by the IDE, no Resharper plugin required.

  • Unload your web app (right click on the project and select ‘Unload Project’)
  • Open the .csproj file in a text editor (right click on the project and select ‘Edit myProjectName.csproj’)
  • At the bottom of the file find the comment which says ‘To modify your build process…’ and insert the following after that comment:

<Target Name="AfterBuild"><AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" /></Target>

Source - Compile Aspx pages at compile time using the AspNetCompiler build task




回答2:


You probably don't want to do this at compile time because compiling views is slow...

What you really want to do is have a NAnt (or something else) task that will XML poke this target into your web .csproj file prior to compiling the source code on your CI server.

This way your developers don't have to put up with the time wasting of the AspNetCompiler every time they do CTRL+SHIFT+B locally in Visual Studio, but you can still alert people to views with syntax errors on the CI server by failing the CI build.

Update: Here is a method that will run your view build outside of Visual Studio, but still on your local PC :)

http://www.luisrocha.net/2011/10/avoiding-mvcbuildviews-build-time.html



来源:https://stackoverflow.com/questions/6613133/asp-net-web-forms-get-aspx-view-errors-at-compile-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!