I have a two step process for producing final output.
First I use the msbuild task to precompile the WCF application
<AspNetCompiler Debug="false" PhysicalPath="$(RootBuildDir)/DeploymentPackages/Helium" TargetPath="$(RootBuildDir)/Packages/theWCFProj" VirtualPath="/theWCFProj" ></AspNetCompiler>
At this point, if I create an application in IIS to the resulting precompiled Packages/theWCFProj directory, everything seems to work.
I then run the command
<Exec Command='aspnet_merge "$(RootBuildDir)/Packages/theWCFProj" -o theWCFProj_aspnet' />
which completes successfully.
However, upon attempting to load the .svc url, or invoke it from a WCF client, I get the following error:
Could not load file or assembly 'App_global.asax, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
I can see however, that the .compiled file is correctly pointing to the merged assembly, because App_global.asax.compiled contains:
<?xml version="1.0" encoding="utf-8"?>
<preserve resultType="8" virtualPath="/theWCFProj/global.asax" hash="ffffffff8d3606ab" filehash="ffffe951d4811dee" flags="150000" assembly="theWCFProj_aspnet" type="ASP.global_asax">
<filedeps>
<filedep name="/theWCFProj/global.asax" />
</filedeps>
</preserve>
The WCF service is hosted in IIS7.
Any ideas on what could be going wrong?
It turns out that someone had added an old version of System.Query.dll directly to the project, which caused warnings during precompilation:
\7b51c9a\assembly\dl3\c17fdca3\777377c3_17a6cc01\System.Query.DLL’
Removing this .dll and the explicit references to it in the .csproj files fixed the problem. Once these precompilation warnings went away, the WCF service no longer had problems accessing App_global.asax