I have an ASP.NET project with two WebJobs, one of the WebJobs publishes fine but the second fails to publish and I get the following error message:
The target "AddScheduledJob" does not exist in the project.
Both WebJobs where set up in the "Run on Demand" mode.
I am struggling to find any explanation for this error and cannot see what is different between my two WebJobs. Anyone come across this?
I eventually found the problem thanks to David Ebbo pointing me in the right direction. I found that I had ended up with two import lines in the .csproj file of one of my WebJobs projects:
<Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.0.2\tools\webjobs.targets" Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.0.2\tools\webjobs.targets')" />
After deleting the first of these everything worked fine. I don't know how this happened but can only assume that something went wrong when I updated the NuGet package.
I had a similar problem when I had existing WebJob SDK projects under an ASP.NET site, and I added a new one. The new one was using a newer version of the Microsoft.Web.WebJobs.Publish package.
I used the "Add Existing Project as Azure WebJob" flow to add it, and then I noticed in the ASP.NET project that there were now two Imports:
<Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.0.10\tools\webjobs.targets" Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.0.10\tools\webjobs.targets')" /> <Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.1.0\tools\webjobs.targets" Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.1.0\tools\webjobs.targets')" />
I simply removed the Import with the older version and that took care of it.