I have code in the top layer of my .Net web application that I'd like to unit test, but when my build server compiles the project using the aspnet_compiler.exe, it makes a .dll file that is not at all usable by another project, i.e. an NUnit test project.
(This is true of ASP .Net web applications and of ASP .Net MVC applications.)
Am I doing something wrong here? Here's my NAnt script that calls the compiler...
<exec program="${asp.compiler.home}/aspnet_compiler.exe" failonerror="true">
<arg value="-nologo"/>
<arg value="-c"/>
<arg value="-f"/>
<arg value="-errorstack"/>
<arg value="-v"/>
<arg value="${project.name}"/>
<arg value="-p"/>
<arg value="${project::get-base-directory()}"/>
<arg value="${web.deploy.dir}\${project.name}"/>
</exec>
You don't need to use aspnet_compiler.exe. That is just a utility application for precompiling your aspx pages to avoid the startup lag when a user hits a page for the first time.
As I understand it, any non-aspx/ascx code in your ASP.NET MVC web application will be compiled normally into a DLL when your solution is built. This DLL is then usable by your NUnit test project. I assume it's those bits you want to test.
So, just build the project using MSBuild from NAnt and forget about aspnet_compiler.exe.