I have the following task in my MSBuild script to deploy to a remote server using Web Deploy (MSDeploy service):
This is now supported by WebDeploy v3.0.. all you need to do is add this line into your publish profile in 'Properties\PublishProfiles'
true
So the resulting publish profile will look something like the following.
true
MSDeploy
(removed)
Default Web Site
True
True
False
WMSVC
sayedha
False
<_SavePWD>True
I have tested this and it does take my application offline during deployment, but unfortunately I still occasionally get the 'PrecompiledApp.config is in used' error.
More information about this can be found here: http://blogs.msdn.com/b/webdev/archive/2013/10/30/web-publishing-updates-for-app-offline-and-usechecksum.aspx