Visual Studio 2019

编程入门 行业动态 更新时间:2024-10-22 17:38:49
本文介绍了Visual Studio 2019-在WebApp中添加WebJob项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的解决方案中,我有一个aspnet核心2.2 WebApp,我想添加一个现有的项目(例如webJob),但是没有选择:从现有项目中添加WebJobs

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

为什么?通过相同的过程,我在其他.Net应用程序上添加了WebJobs,并且该选项显示在Visual Studio 2019中

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

编辑

使用英语更改了图像.有时会显示添加">现有项目"为Azure WebJobs,但如果单击它,则会显示此错误:

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:

(所选项目是aspnet.core 2.2.WebApp)

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

单击此键后,将不再显示添加">作为Azure WebJobs的现有项目".

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

推荐答案

更新:

例如,如果要手动将控制台应用程序部署为webjob.

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

  • 创建控制台应用程序.下面是我的代码:

  • Create a Console app. Below is my code:

    使用系统;

    命名空间testwebjob{班级计划{静态void Main(string [] args){Console.WriteLine(这是我的第一个网络工作!");}}}

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

    2.构建控制台应用程序,然后右键单击并选择以下内容:

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

    3.转到bin-> Debug-> xxx,然后您将找到一个包含以下文件的文件夹,添加run.cmd并将其压缩.

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

    这是我的run.cmd的内容:

    This is the content of my run.cmd:

    @echo off dotnet testwebjob.dll

    4.转到天蓝色的Web应用程序,搜索webjob.点击添加并上传zip文件.

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

    5.然后,Web作业已部署.这是日志:

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

    原始答案:

    从文档

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

    实际上,已经有关于此的反馈.您可以在这里投票:

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

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

    也许您可以尝试不使用此功能,并选择在部署Web应用程序后部署Web作业.:)

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

  • 更多推荐

    Visual Studio 2019

    本文发布于:2023-11-15 19:08:53,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1597178.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Visual   Studio

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!