This week I ran into a minor annoyance with our process for building web projects. We use VS2005 web application projects, along with web deployment projects, and in the deployment project we choose not to make the web site updatable — all the aspx and ascx files are compiled. We then use MSBuild to copy everything into an output directory like so:
With the non-updatable option selected in the web deployment project, all the .ascx and .master files are removed during compilation. They’re compiled, so we don’t need them anymore, right? Right. Well, when we copy files to the output directory, our /MasterPages and /UserControls directories don’t have any files, so those directories don’t get recreated in the output. Unfortunately, it looks like we need those empty directories. When we run the site, ASP.NET seems unable to find either the master pages or any user controls if the directories they were originally in don’t exist.
Our workaround is to create an empty “dummy.config” file in each directory that we need to have show up in the running site. Config files are harmless, and ASP.NET won’t let them be retrieved through a browser. Alternatively, we could add a step to our build file that deletes all the dummy.config’s after copying to the output.
My question is: Why does ASP.NET need the empty directories in order to locate the compiled .master and .ascx classes? Or are we just doing something wrong in the deployment project or in our overall build process?