For future reference, I've found exactly what is required to enable deployments for anything other than web services/projects. The reason the DeployOnBuild parameter doesn't do anything for anything other than web projects is that the project file needs to include the webapplication.targets and also a PropertyGroup containing the path to the VSToolsPath.
This link here gave me a good introduction as to how web deployments work and how to integrate this into my project to deploy services:
To pass parameters into MSBuild you need a .pubxml file (called the publishing profile) within the PublishProfiles folder under your project properties folder.
I needed the following in the .csproj file:
<PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> </PropertyGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
If you need the pre-sync/post-sync commands of MSDeploy, unfortunately this is not available from MSBuild. To do achieve this functionality you need to have a X.Wpp.Targets (where X is your project name) inside your project root folder.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="UninstallService" BeforeTargets="MSDeployPublish"> <!-- Do exec tasks here --> </Target> <Target Name="InstallService" AfterTargets="MSDeployPublish"> <!-- Do exec tasks here --> </Target> </Project>