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

无人久伴 提交于 2019-12-12 10:44:12

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/46848211/asp-net-webdeploy-failing-addscheduledjob-does-not-exist-in-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!