ASP.NET Webdeploy failing; AddScheduledJob does no

2019-06-20 02:15发布

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.

2条回答
劳资没心,怎么记你
2楼-- · 2019-06-20 02:30

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.

查看更多
相关推荐>>
3楼-- · 2019-06-20 02:42

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.

查看更多
登录 后发表回答