I have written about the functionality of Web Deployment Projects for Visual Studio 2005, and after upgrading also downloaded Web Deployment Projects for Visual Studio 2008. Not much has changed in the meantime, but there are some noteworthy differences between Web Site Projects and Web Application Projects.
The main issue when compiling a Web App Project using aspnet_compiler (instead of msbuild) is that some files (such as the .csproj and .csproj.user files) and directories are copied to the output, as they do not exist in Web Site projects.
Thus the build+publish process should remove the files not required for execution (we are dealing with compiled applications, after all).
This is the updated batch file for building web application projects:
@echo off if "%1"=="" goto errnoparam if "%2"=="" goto errnoparam if not exist %2\nul goto errnotfound setlocal call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 echo on set base=c:\path-to\publish\%1 if not exist %base%\nul md %base% rd /s /q %base% echo compiling to %base% aspnet_compiler -v /%1 -f -d -c -p %2 %base% aspnet_merge %base% -w %1.pages -debug echo web compiled to %base% pushd %base% del *.csproj del *.csproj.user rd /s /q Code rd /s /q obj rd /s /q Properties rd /s /q "Web References" ren web.config web.publish.config popd endlocal goto end :errnoparam echo usage: %0 webname sourcepath goto end :errnotfound echo web %1 not found goto end :end
The batch file takes two parameters: the assembly name and the path to the web app project (assuming that web app projects do not reside in the inetpub\wwwroot directory, as was the case with web site projects).
It calls aspnet_compiler to compile pages, controls, and code-behind, and aspnet_merge to merge all markup files (.aspx, .ascs, etc) into an assembly names *.pages. Afterwards it cleans up unnecessary files and directories, and renames web.config (to avoid accidentally overriding web.config in production environments).
Edit 14.9.2010: It seems the runtime requires directories originally containing .ascx files to be present in the published web, even though the directory is empty.