Visual Studio 2019 - Adding WebJob project in WebApp

房东的猫 提交于 2021-01-28 05:36:08

问题


In my solution i have an aspnet core 2.2 WebApp, and i want to add an existent project like webJob but there isn't the option: Add WebJobs from existent project

Why? With the same procedure i add WebJobs on my other .Net application, and this option is shown in visual studio 2019

EDIT

Changed images with english language. Sometimes the Add > Existing project as Azure WebJobs it's showned but if I click on it it shows this error:

(the selected project is the aspnet.core 2.2. WebApp)

After this click , the Add > Existing project as Azure WebJobs is no longer visible.


回答1:


Update:

For example, if you want to deploy a console app as webjob manually.

  1. Create a Console app. Below is my code:

    using System;

    namespace testwebjob { class Program { static void Main(string[] args) { Console.WriteLine("This is my first webjob!"); } } }

2.Build the console app, then right click and choose this:

3.Go to bin -> Debug -> xxx, then you will find a folder with below files,add a run.cmd and zip them.

This is the content of my run.cmd:

@echo off

dotnet testwebjob.dll

4.Go to azure web app, search webjob. Click add and upload the zip file.

5.Then the web job has be deployed. This is the log:

Original Answer:

From the documentation, you will find that 'Enable automatic WebJobs deployment with a web project' is a feature supported by .net framework web app. It seems .net core web app is not supported.

In fact there is already a feedback about this. You can vote here:

https://developercommunity.visualstudio.com/content/problem/806009/existing-project-as-azure-webjob-results-in-generi.html

Maybe you can try not to use this feature and choose to deploy the web job after the web app is deployed.:)



来源:https://stackoverflow.com/questions/61895100/visual-studio-2019-adding-webjob-project-in-webapp

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