net Web表单,在编译时获得aspx/view错误?

时间:2021-02-03 15:29:13

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.

我知道mvc2可以做到这一点,但是visual studio(2010)/resharper(6)是否可以在编译时检查aspx页面上的错误并停止构建?Resharper可以很好地检测错误,所以看起来应该有一种方法来集成对构建过程中所有aspx页面的检查。

Any tips?

任何建议吗?

2 个解决方案

#1


18  

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.

是的,你可以。以下步骤将使.aspx文件编译为IDE调用的普通构建的一部分,不需要Resharper插件。

  • Unload your web app (right click on the project and select ‘Unload Project’)
  • 卸载web应用程序(右键单击项目,选择卸载项目)
  • Open the .csproj file in a text editor (right click on the project and select ‘Edit myProjectName.csproj’)
  • 在文本编辑器中打开.csproj文件(右键单击项目并选择' 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>

<目标name = " afterbuild> < AspNetCompiler VirtualPath =“临时”PhysicalPath = " $()管理扫描”/ > < /目标>

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

源-使用AspNetCompiler build任务在编译时编译Aspx页面

#2


1  

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.

您真正想要做的是拥有一个NAnt(或其他)任务,该任务将在编译CI服务器上的源代码之前将该目标插入web .csproj文件。

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.

这样,开发人员就不必忍受每次在Visual Studio中本地执行CTRL+SHIFT+B时AspNetCompiler的时间浪费,但您仍然可以通过CI构建失败来提醒人们在CI服务器上使用语法错误的视图。

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

更新:这里有一个方法可以在Visual Studio之外运行您的视图构建,但是仍然可以在您的本地PC上运行:)

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

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

#1


18  

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.

是的,你可以。以下步骤将使.aspx文件编译为IDE调用的普通构建的一部分,不需要Resharper插件。

  • Unload your web app (right click on the project and select ‘Unload Project’)
  • 卸载web应用程序(右键单击项目,选择卸载项目)
  • Open the .csproj file in a text editor (right click on the project and select ‘Edit myProjectName.csproj’)
  • 在文本编辑器中打开.csproj文件(右键单击项目并选择' 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>

<目标name = " afterbuild> < AspNetCompiler VirtualPath =“临时”PhysicalPath = " $()管理扫描”/ > < /目标>

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

源-使用AspNetCompiler build任务在编译时编译Aspx页面

#2


1  

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.

您真正想要做的是拥有一个NAnt(或其他)任务,该任务将在编译CI服务器上的源代码之前将该目标插入web .csproj文件。

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.

这样,开发人员就不必忍受每次在Visual Studio中本地执行CTRL+SHIFT+B时AspNetCompiler的时间浪费,但您仍然可以通过CI构建失败来提醒人们在CI服务器上使用语法错误的视图。

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

更新:这里有一个方法可以在Visual Studio之外运行您的视图构建,但是仍然可以在您的本地PC上运行:)

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

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