Two things to watch out for with _CopyWebApplication
1. You need to resolve the references by making an explicit call to "ResolveReferences"
2. You need to specify both the output / virtual directory path *and* the web project output path, if you don't (and as noted in the linked blog post) the references will only get copied one level deep!
However, once it's working, is well worth the effort and of course invaluable for that continuous integration!!!
<MSBuild Projects ="%(WebProject.path)" Properties ="OutDir=$(DestFolder)\%(WebProject.Identity)\BIN\; WebProjectOutputDir=$(DestFolder)\%(WebProject.Identity)\" Targets="ResolveReferences; _CopyWebApplication" />
Update: We have has some issues with this approach, principle is what appears to be a bug within the ResolveReferences target.
We always build a solution containing the web services to deploy and we do this first.
However (and I am not sure exactly what triggers this) the corecompile target can be called if the framework thinks an assembly is "out of date" and needs re-compliling. As I say this shouldn't happen for us given we build the solution up-front, but sometimes it does.
When this does happen (on a project by project basis) and if it happens where a project has either a direct or indirect reference to another project AND that other project has a binary/file ref to a MS assembly - in this example System.Web.Services then we hit some trouble.
The corecompile will call the compiler directly passing in a list of commands including all the dependancies, but in this case System.Web.Services is a second level dependancy (it's not directly referenced by the assembly being built, but is by a child assembly) and it doesn't get added causing an exception.
I am still not sure if there's a fix for this, but this problem was in context of some old vs2005 projects and I have a feeling this wouldn't be an issue with 2008 and 2010.
Anyway for now we are using a Folder.Copy target (given that we manage GAC dependancies and we pre build the solution) and this is fine for us, for now.