I spent most of the morning tracking down what appears to be a significant bug in the way Visual Studio 2005 compiles web sites.
The short of it: If you have mismatched ASP.NET tags in an ASPX file in a directory of your website, all subsequent directories will not be compiled. Your solution will show "Build Succeeded", even though there are syntax errors in those subsequent directories.
Here's an example...
To begin, i have a fairly standard ASP.NET solution, containing a single web site (not a web project), and a class library. We're primarily focused on the web site...
You'll see that there are a number of directories, each containing an ASPX page. As you're probably aware, in ASP.NET 2.0, when you "build" the site, the ASP.NET compiler will compile each of these directories into their own assembly.
Directory1 contains a single, error-free aspx page.
Directory2 is where the problem code exists. It contains an ASP.NET tag which does not have a matching end tag. In this case, it's an asp:Hyperlink...
Directory3 has some more problem code, in this case, it's a nasty syntax error in the code behind file.
Directory4 contains ANOTHER mismatched tag, same as Directory1.
Now, one would expect a couple of things to happen when you "Build" the solution... First, the compiler should catch the mismatched tag and report it as an error. Second, the compiler should definately catch the C# syntax error in the code-behind, and report it as well.
Oddly enough, this is not the case... If I right-click the solution, and select "Rebuild Solution", here's what happens...
2 succeeded?!?! WTF!!!!
Visual Studio indeed reports that the build succeeded. Pay close attention though, it STOPPED BUILDING DIRECTORIES after Directory2.
After trying a number of things to get this working (compiling, cleaning solution, publishing, etc), I finally tried to compile the web site manually, using the aspnet_compiler tool.
At first try, it doesn't report any errors as well...
At this point I thought all was lost, until I discovered that the aspnet_compiler has a flag errorstack, which "Shows extra debuggin information that can help debug certain conditions." How ambiguous.
But, I tried it anyway...

Progress! Finally, I get an ERROR MESSAGE! A really helpful one at that
HttpParseException: Unexpected end of file looking for </asp:HyperLink> tag.
Now, armed with this information, I can fix the problem. Doing so, and rebuilding the solution reveils our sytax error!
Sucess! (Sort of)..
Final Thoughts
There's a couple of things to note:
- It appears to be Directory Order specific. That is, it compiles the directories in order, and will blow up on the syntax errors if the mismatched tag is AFTER.
- If you PUBLISH the website, the build will succeed, and the publish will succeed, but all of the files in the destination directory will have been removed, with no new ones in their place!
I still have no solution for my problem, short of compiling the website every time (or every so often) with aspnet_compiler and specifying the errorstack flag.
I've played around a bit with various settings in Visual Studio, but with no luck. I even tried this on another developers machine who had installed SP1, also with no luck.
If anyone has a suggestion, leave it in the comments!