0

阅读了这里的建议:https ://docs.microsoft.com/en-gb/azure/app-service/webjobs-dotnet-deploy-vs#deploy-to-azure-app-service我感觉没有更进一步寻求通过 bitbucket/source control 链接将 .net 核心控制台应用程序部署为 Web 作业的解决方案,因为该文章仅讨论“如何使用 Visual Studio 的 Publish To Azure 部署 .net 核心应用程序”和“如何设置 .用于部署的网络标准应用程序 [通过位存储桶/源代码控制集成] 通过 Azure kudu” - 我的情况似乎介于这两者之间?

如何配置我的解决方案,其中包含一个我想作为 Web 作业运行的 Web 应用程序(部署良好且工作正常)和一个控制台应用程序(在本地构建,不是在 Azure 上构建)?

目前,当我检查 Azure 上的构建日志时,即使本地构建过程似乎可以构建它,kudu 甚至都不会费心构建 csproj:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
  Restore completed in 803.97 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.DIExtension\ChatRoom.BL.DIExtension.csproj.
  Restore completed in 118.75 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.Interfaces\ChatRoom.BL.Interfaces.csproj.
  Restore completed in 111.72 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.Services\ChatRoom.BL.Services.csproj.
  Restore completed in 460.41 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.SignalR\ChatRoom.SignalR.csproj.
  Restore completed in 98.55 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.ViewModels\ChatRoom.BL.ViewModels.csproj.
  Restore completed in 137.75 ms for D:\home\site\repository\ChatRoom\ChatRoom.Cache\ChatRoom.Cache.csproj.
  Restore completed in 91.49 ms for D:\home\site\repository\ChatRoom\ChatRoom.Common\ChatRoom.Common.csproj.
  Restore completed in 126.71 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.DIExtension\ChatRoom.DL.DIExtension.csproj.
  Restore completed in 92.71 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.Entities\ChatRoom.DL.Entities.csproj.
  Restore completed in 97.46 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.Interfaces\ChatRoom.DL.Interfaces.csproj.
  Restore completed in 153.15 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.Repositories\ChatRoom.DL.Repositories.csproj.
  Restore completed in 109.98 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.UnitOfWork\ChatRoom.DL.UnitOfWork.csproj.
  Restore completed in 12.85 ms for D:\home\site\repository\ChatRoom\ChatRoom.Localization\ChatRoom.Localization.csproj.
  Restore completed in 76.23 ms for D:\home\site\repository\ChatRoom\ChatRoom.MessageBroker\ChatRoom.MessageBroker.csproj.
  Restore completed in 215.29 ms for D:\home\site\repository\ChatRoom\ChatRoom.Replication\ChatRoom.Replication.csproj.
  Restore completed in 189.31 ms for D:\home\site\repository\ChatRoom\ChatRoom.DrawingGenerator.Consumer\ChatRoom.DrawingGenerator.Consumer.csproj.
  Restore completed in 1.2 sec for D:\home\site\repository\ChatRoom\ChatRoom\ChatRoom.csproj.
  Restore completed in 592.52 ms for D:\home\site\repository\ChatRoom\ChatRoom\ChatRoom.csproj.
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 2.62 sec for D:\home\site\repository\ChatRoom\ChatRoom.BL.DIExtension\ChatRoom.BL.DIExtension.csproj.
  Restore completed in 195.02 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.Interfaces\ChatRoom.BL.Interfaces.csproj.
  Restore completed in 108.83 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.Services\ChatRoom.BL.Services.csproj.
  Restore completed in 359.89 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.SignalR\ChatRoom.SignalR.csproj.
  Restore completed in 97.73 ms for D:\home\site\repository\ChatRoom\ChatRoom.BL.ViewModels\ChatRoom.BL.ViewModels.csproj.
  Restore completed in 103.01 ms for D:\home\site\repository\ChatRoom\ChatRoom.Cache\ChatRoom.Cache.csproj.
  Restore completed in 83.57 ms for D:\home\site\repository\ChatRoom\ChatRoom.Common\ChatRoom.Common.csproj.
  Restore completed in 161.88 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.DIExtension\ChatRoom.DL.DIExtension.csproj.
  Restore completed in 91.2 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.Entities\ChatRoom.DL.Entities.csproj.
  Restore completed in 89.98 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.Interfaces\ChatRoom.DL.Interfaces.csproj.
  Restore completed in 108.06 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.Repositories\ChatRoom.DL.Repositories.csproj.
  Restore completed in 111.54 ms for D:\home\site\repository\ChatRoom\ChatRoom.DL.UnitOfWork\ChatRoom.DL.UnitOfWork.csproj.
  Restore completed in 7.71 ms for D:\home\site\repository\ChatRoom\ChatRoom.Localization\ChatRoom.Localization.csproj.
  Restore completed in 82.28 ms for D:\home\site\repository\ChatRoom\ChatRoom.MessageBroker\ChatRoom.MessageBroker.csproj.
  Restore completed in 178.2 ms for D:\home\site\repository\ChatRoom\ChatRoom.Replication\ChatRoom.Replication.csproj.
  Restore completed in 834.91 ms for D:\home\site\repository\ChatRoom\ChatRoom\ChatRoom.csproj.
  Restore completed in 328.17 ms for D:\home\site\repository\ChatRoom\ChatRoom\ChatRoom.csproj.
  ChatRoom.Cache -> D:\home\site\repository\ChatRoom\ChatRoom.Cache\bin\Release\netcoreapp2.2\ChatRoom.Cache.dll
  ChatRoom.Common -> D:\home\site\repository\ChatRoom\ChatRoom.Common\bin\Release\netcoreapp2.2\ChatRoom.Common.dll
  ChatRoom.DL.Entities -> D:\home\site\repository\ChatRoom\ChatRoom.DL.Entities\bin\Release\netcoreapp2.2\ChatRoom.DL.Entities.dll
  ChatRoom.MessageBroker -> D:\home\site\repository\ChatRoom\ChatRoom.MessageBroker\bin\Release\netcoreapp2.2\ChatRoom.MessageBroker.dll
  ChatRoom.BL.ViewModels -> D:\home\site\repository\ChatRoom\ChatRoom.BL.ViewModels\bin\Release\netcoreapp2.2\ChatRoom.BL.ViewModels.dll
  ChatRoom.BL.Interfaces -> D:\home\site\repository\ChatRoom\ChatRoom.BL.Interfaces\bin\Release\netcoreapp2.2\ChatRoom.BL.Interfaces.dll
  ChatRoom.DL.Interfaces -> D:\home\site\repository\ChatRoom\ChatRoom.DL.Interfaces\bin\Release\netcoreapp2.2\ChatRoom.DL.Interfaces.dll
  ChatRoom.DL.Repositories -> D:\home\site\repository\ChatRoom\ChatRoom.DL.Repositories\bin\Release\netcoreapp2.2\ChatRoom.DL.Repositories.dll
  ChatRoom.Localization -> D:\home\site\repository\ChatRoom\ChatRoom.Localization\bin\Release\netstandard2.0\ChatRoom.Localization.dll
  ChatRoom.Replication -> D:\home\site\repository\ChatRoom\ChatRoom.Replication\bin\Release\netcoreapp2.2\ChatRoom.Replication.dll
  ChatRoom.BL.Services -> D:\home\site\repository\ChatRoom\ChatRoom.BL.Services\bin\Release\netcoreapp2.2\ChatRoom.BL.Services.dll
  ChatRoom.BL.DIExtension -> D:\home\site\repository\ChatRoom\ChatRoom.BL.DIExtension\bin\Release\netcoreapp2.2\ChatRoom.BL.DIExtension.dll
  ChatRoom.SignalR -> D:\home\site\repository\ChatRoom\ChatRoom.BL.SignalR\bin\Release\netcoreapp2.2\ChatRoom.SignalR.dll
  ChatRoom.DL.UnitOfWork -> D:\home\site\repository\ChatRoom\ChatRoom.DL.UnitOfWork\bin\Release\netcoreapp2.2\ChatRoom.DL.UnitOfWork.dll
  ChatRoom.DL.DIExtension -> D:\home\site\repository\ChatRoom\ChatRoom.DL.DIExtension\bin\Release\netcoreapp2.2\ChatRoom.DL.DIExtension.dll
  ChatRoom -> D:\home\site\repository\ChatRoom\ChatRoom\bin\Release\netcoreapp2.2\ChatRoom.dll
  ChatRoom -> D:\local\Temp\8d74117af5751d5\
Creating app_offline.htm
KuduSync.NET from: 'D:\local\Temp\8d74117af5751d5' to: 'D:\home\site\wwwroot'
Copying file: 'ChatRoom.BL.DIExtension.dll'
Copying file: 'ChatRoom.BL.DIExtension.pdb'
Copying file: 'ChatRoom.BL.Interfaces.dll'
Copying file: 'ChatRoom.BL.Interfaces.pdb'
Copying file: 'ChatRoom.BL.Services.dll'
Copying file: 'ChatRoom.BL.Services.pdb'
Copying file: 'ChatRoom.BL.ViewModels.dll'
Copying file: 'ChatRoom.BL.ViewModels.pdb'
Copying file: 'ChatRoom.Cache.dll'
Copying file: 'ChatRoom.Cache.pdb'
Copying file: 'ChatRoom.Common.dll'
Copying file: 'ChatRoom.Common.pdb'
Copying file: 'ChatRoom.deps.json'
Copying file: 'ChatRoom.DL.DIExtension.dll'
Copying file: 'ChatRoom.DL.DIExtension.pdb'
Copying file: 'ChatRoom.DL.Entities.dll'
Copying file: 'ChatRoom.DL.Entities.pdb'
Copying file: 'ChatRoom.DL.Interfaces.dll'
Copying file: 'ChatRoom.DL.Interfaces.pdb'
Copying file: 'ChatRoom.DL.Repositories.dll'
Copying file: 'ChatRoom.DL.Repositories.pdb'
Copying file: 'ChatRoom.DL.UnitOfWork.dll'
Copying file: 'ChatRoom.DL.UnitOfWork.pdb'
Copying file: 'ChatRoom.dll'
Copying file: 'ChatRoom.Localization.dll'
Copying file: 'ChatRoom.Localization.pdb'
Copying file: 'ChatRoom.MessageBroker.dll'
Copying file: 'ChatRoom.MessageBroker.pdb'
Copying file: 'ChatRoom.pdb'
Copying file: 'ChatRoom.Replication.dll'
Copying file: 'ChatRoom.Replication.pdb'
Copying file: 'ChatRoom.runtimeconfig.json'
Copying file: 'ChatRoom.SignalR.dll'
Copying file: 'ChatRoom.SignalR.pdb'
Copying file: 'ar-AE\ChatRoom.Localization.resources.dll'
Copying file: 'de-DE\ChatRoom.Localization.resources.dll'
Copying file: 'ru-Ru\ChatRoom.Localization.resources.dll'
Deleting app_offline.htm
Finished successfully.

它克隆将成为 webjob 的应用程序并为其恢复 nuget 包:

    Restore completed in 189.31 ms for 
D:\home\site\repository\ChatRoom\ChatRoom.DrawingGenerator.Consumer\ChatRoom.DrawingGenerator.Consumer.csproj

但是后来它再也没有被提及,并且在 azure 服务上没有明显的该项目的二进制文件..

我希望我可以将它们配置为输出到按惯例变成网络作业的文件夹集

4

1 回答 1

0

如何配置我的解决方案,其中包含我想作为 Web 作业运行的 Web 应用程序(部署良好且工作正常)和控制台应用程序(在本地构建,不是在 Azure 上构建)?

我向 Azure WAS 构建的项目添加了一个构建后事件,其形式为:

dotnet publish "%25DEPLOYMENT_SOURCE%25\MySolutionName\MyWebJobProject\MyWebJobProject.csproj" --output "%25DEPLOYMENT_TEMP%25\app_data\jobs\continuous\mywebjob" --configuration Release

这些%25是必要的-> 它们%在读取 csproj XML 时解码%DEPLOYMENT_SOURCE%为传递给命令行的含义。如果你%DEPLOYMENT_SOURCE%直接进入 VS 中的 Post Build Event GUI %DE,无论是什么字符,它都会被解码为 0xDE,并且你会在日志中看到带有替换字符的错误 ...</p>

  • %DEPLOYMENT_SOURCE%大概是D:\home\site\repository。文件似乎在此根目录中构建,然后作为 DLL 发布到临时位置:
  • %DEPLOYMENT_TEMP%是类似的东西D:\local\temp\abcdef1234。将 DLL 作为发布步骤移动到此处后,KuduSync.Net.exe 运行并将它们镜像回来
  • KuduSync.Net.exe本质上是一个镜像工具;它会从您的实时站点中删除上次部署但这次未部署的文件和目录,并添加这次部署但上次未部署的新文件。它不会触及未更改的文件。这样,如果您的站点创建自己的文件(即不是部署的一部分),那么它们将不会被丢弃
  • 一旦您的 webjob 项目发布到 %DEPLOYMENT_TEMP% 位置,在app_data\jobs\continuous\somename子文件夹中,KuduSync 会将其同步回实时站点文件层次结构,并将显示在 webjobs 仪表板中

仅留下几行关于如何让 dotnet 控制台应用程序作为 Web 作业运行的内容。最简单的路线似乎是:

  • 添加一个名为run.bat您的项目的文件,将其构建操作设置为Content并复制到输出文件夹到Copy Always
  • 在文件里面放dotnet NameOfYourCoreApp.dll

使用纯 ASCII 编码而不是 UTF8 保存文件,否则字节顺序标记将构成第一行命令的一部分,您的应用将无法运行


请记住,网络作业可以是不同类型的触发器;适当编辑“连续”一词

目前,当我检查 Azure 上的构建日志时,看起来 kudu 甚至都没有费心构建 csproj

如果 azure IS 构建的 csproj 不依赖它,那么它就不会构建它。这无关紧要,因为正在构建的项目上的构建后事件会构建未构建的项目。

于 2019-09-25T18:04:05.443 回答