Oct 1, 2012

ASP.NET ASPX Pre-compile Errors

MS Visual Studio, by default, does not compile a project’s ASPX/ASCX pages until runtime (via IIS Just-In-Time compiler).  Unfortunately, the IIS JIT compiler is very forgiving, ignoring some syntax errors, missing custom tag libraries, un-handled events, etc.  Therefore, these types of errors may exist in ASPX pages even though the web page “works”.


This Visual Studio Post-Build Event will show these hidden ASPX errors in the Error Window when a normal REBUILD ALL is performed.


Framework 2.0, 3.0, 3.5:
VS2010 -> Project -> Properties -> Build Events -> Post-build event command line:
"%systemroot%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler" -errorstack -c -v "$(TargetName)" -p "$(ProjectDir)\"


Framework 4.0, 4.5:
VS2010 -> Project -> Properties -> Build Events -> Post-build event command line:
"%systemroot%\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler" -errorstack -c -v "$(TargetName)" -p "$(ProjectDir)\"


64-bit Framework 2.0, 3.0, 3.5:
VS2010 -> Project -> Properties -> Build Events -> Post-build event command line:
"%systemroot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_compiler" -errorstack -c -v "$(TargetName)" -p "$(ProjectDir)\"


64-bit Framework 4.0, 4.5:
VS2010 -> Project -> Properties -> Build Events -> Post-build event command line:
"%systemroot%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler" -errorstack -c -v "$(TargetName)" -p "$(ProjectDir)\"

No comments: