Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Webdeploy failing; AddScheduledJob does not exist in project

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?

Edited

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.

like image 393
dmb_acunim Avatar asked Oct 20 '17 11:10

dmb_acunim


2 Answers

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.

like image 150
Sean Avatar answered Sep 21 '22 17:09

Sean


In your WebJob project delete the webjob-publish-settings.json file also delete the webjobs-list.json from your WebAPI project.

Now, In WebAPI Project Right Click > Add > Existing Project As Azure Web Job, This will recreate the webjob-publish-settings.json and webjobs-list.json files and should fix the issue.

like image 45
Jag Kandasamy Avatar answered Sep 20 '22 17:09

Jag Kandasamy