I had a rather old Azure web job that I always deployed by creating a .zip myself and uploading it to the portal manually. I decided to use the nice feature inside Visual Studio 2015 that publishes the project for you. But when I walked through the wizard and hit “publish” I received the following error:
Error MSB4057: The target "MSDeployPublish" does not exist in the project.
I realized a couple things. First, you have to add the Microsoft.Web.WebJobs.Publish.1.0.11 package from Nuget. Even though VS has the publish to Web Job action, it doesn’t automatically add that package to your project.
Once you add it, you’re still screwed. VS doesn’t automatically modify your .csproj file to use this package. To do so, you need manually hack your .csproj file. Easiest way is to unload it in VS and add the following line right after the CSharp targets – I’ve included it below for context:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.0.11\tools\webjobs.targets" Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.0.11\tools\webjobs.targets')" />
With that, everything worked!
Note that I got into this whole scenario because for some mysterious reason, I could no longer successfully upload projects through either the legacy portal or the new one, so if you hit issue, my recommendation is to publish through VS, which is much cleaner anyway.