Pages

Monday, July 21, 2014

Reminder: If you develop WebForms, you should be doing this…

There are plenty of posts out there about using the aspnet_compiler.exe tool.

http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html
http://odetocode.com/blogs/scott/archive/2006/10/17/what-can-aspnet_compiler-exe-do-for-me.aspx

I’m not writing this to shed any new light on the subject. I'm writing this to remind developers that you should be using this tool… period.

It’s easy.

1. Add it as a Post Build event in your project:
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v / -p "$(ProjectDir)"
Or

2. Add it as an MSBUILD target in your projects XML configuration:
<target name="AfterBuild">
    <message importance="high" text="Starting AspNetCompiler for $(ProjectName)" />
    <aspnetcompiler clean="true" debug="true" force="true" physicalpath="$(ProjectDir)" targetpath="$(ProjectDir)\obj\aspnet_compiler" virtualpath="/" />
    <message importance="high" text="Completed AspNetCompiler for $(ProjectName)" />
</target>

After enabling pre-compilation you may just find that your project has more issues that you previously thought.


It makes too much sense to not do this. It will save your butt at least once… I promise.

No comments:

Post a Comment