Cannot create an MSDeploy package for an Azure Web Job project as part of an automated build/

I like web deploy as a means to package up websites for deployment. I like the way I only need to add

1/p:DeployOnBuild=True;PublishProfile=Release

as an MSBuild argument to get the package produced as part of an automated build. This opening up loads of deployment options

I recently hit an issue packaging up a solution that contained an Azure WebSite and an Azure Web Job (to be hosted in the web site). It is easy to add the web job so that it is included in the Web Deploy package. Once this was done we could deploy from Visual Studio, or package to the local file system and see the web job EXE in the app_datajobs folder as expected.

The problems occurred when we tried to get TFS build to create the deployment package using the arguments shown above. I got the error

1The value for PublishProfile is set to 'Release', expected to find the file at 'C:vNextBuild\_work4253ff91BMSrcMyWebJobPropertiesPublishProfilesRelease.pubxml' but it could not be found.

The issue is that there is a Publish target for the web jobs project type, but if run from Visual Studio it actually creates a ClickOnce package. This wizard provides no means create an MSDeploy style package.

MSBuild is getting confused as it expects there to be this MSDeploy style package definition for the web job projects, even though it won’t actually use it as the Web Job EXE will be copied into the web site deployment package.

The solution was to add a dummy PublishProfilesRelease.pubxml file into the properties folder of the web jobs project.

 1<?xml version="1.0" encoding="utf-8"?>  
 2<Project ToolsVersion="4.0" xmlns="[http://schemas.microsoft.com/developer/msbuild/2003"](http://schemas.microsoft.com/developer/msbuild/2003")\>  
 3  <PropertyGroup>  
 4    <WebPublishMethod>Package</WebPublishMethod>  
 5    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>  
 6    <LastUsedPlatform>Any CPU</LastUsedPlatform>  
 7    <SiteUrlToLaunchAfterPublish />  
 8    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>  
 9    <ExcludeApp\_Data>False</ExcludeApp\_Data>  
10    <DesktopBuildPackageLocation />  
11    <PackageAsSingleFile>true</PackageAsSingleFile>  
12    <DeployIisAppPath />  
13    <PublishDatabaseSettings/>  
14    </PropertyGroup>  
15</Project>

Note: I had to add this file to source control via the TFS Source Code Explorer as Visual Studio does not allow you add folders/files manually under the properties folder.

Once this file was added my automated build worked OK, and I got my web site package including the web job.