Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Compile Aspx pages at compile time using the AspNetCompiler build task August 18, 2010

Filed under: Asp.Net,Web — Rupert Bates @ 1:20 pm

By default Asp.Net web applications don’t compile aspx files (only the code behind). This means that you can have errors in them which don’t appear until you actually hit the page.

To change this so that your aspx files get compiled along with all the rest of your code do the following:

  • 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>

 

Leave a comment