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)" />


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s