When using the aspnet_compiler.exe and having a theme defined in your web.config file, the compiler puts that theme into the page directive for every page file.
Not sure why they do this? I may be a performance thing. In my case however it is not helpful because after I uploaded my pre-compiled site to the production server, I'm using it for several different actual web sites which all use different themes. Because the page directive overrides the web.config setting all the sites end up with the same theme, the one that was set in web.config on my development machine.
So I added another step to my deployment script, after compiling the site I call:
rxfind.exe c:\projects\mysite\wwwroot\*.as?x /P:" theme=\"[a-z0-1]*\" " /R:" " /I /S /B:2
rxfind is a nice little .net based replace strings in files tool.