Hopefully this will save someone else (or my future self) the couple of hours my colleague and I spent wrestling with ASP.Net to get this to work.
We have an ASP.Net 3.5 Web Application project and were trying to pair it up with a Web Deployment Project. This first problem we faced was with ILMerge complaining during the build process for the web deployment project. It said "An error occurred when merging assemblies: ILMerge.Merge: The target assembly 'cwSharp2' lists itself as an external reference.”. We fixed this thanks to a comment by JohnC on a post by Rick Strahl. You have to make sure that the output assembly for the Web Deployment project is different to the Web Application project – we called ours [Project].Pages.
The next problem didn’t reveal itself until we actually tried running the website as compiled by the Web Deployment project. When we tried browsing one of the pages we got errors like “Compiler Error Message: CS0433: The type '**' exists in both '***.dll’ and ‘***.dll'”. I searched, and – bing – out popped the answer: you have to right-click your web application project and click “Convert to Web Application”; doesn’t quite make sense, I know, but it works!