如何将.NET Core 3.1项目部署到webjob上?

问题描述 投票:0回答:1

我们如何在 Azure Devops 中设置构建/发布管道以自动将 .NET Core 3.1 项目部署为 Web 作业?

我在门户中手动创建了一个 Web 应用程序:

enter image description here

我正在尝试使用 Azure Devops 部署以下项目:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\BusinessManager\BusinessManager.csproj" />
    <ProjectReference Include="..\Models\Models.csproj" />
    <ProjectReference Include="..\Service\Service.csproj" />
  </ItemGroup>
</Project>

这是我的构建任务

enter image description here

dotnet build
任务详情:

enter image description here

dotnet publish
任务详情:

enter image description here

我在构建中遇到以下错误

C:\Program Files\dotnet\sdk\9.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: D:\a\1\s\Controller.Tests\appsettings.json, D:\a\1\s\API\appsettings.json. [D:\a\1\s\Controller.Tests\Controller.Tests.csproj]

##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1  
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build    
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting  
##[error]Dotnet command failed with non-zero exit code on the following projects : [ '' ]  
Finishing: dotnet publish

禁用

dotnet publish
并启用工件掉落时,构建成功:

enter image description here

构建工件发布后触发发布:

enter image description here

但是,我没有看到门户中发布的网络作业

enter image description here

问题

  1. 什么表明网络作业已正确发布到门户?
  2. 使用 DevOps 构建 .NET Core 3.1 项目的正确方法是什么?
  3. 如果这个问题模糊和抽象,我深表歉意,如果您提供一些建设性的评论,我很乐意更新这个问题并使其更加集中和可回答。
azure-devops azure-pipelines azure-web-app-service asp.net-core-3.1 azure-webjobs
1个回答
0
投票

⚠️警告

.NET Core 3.1 不再受支持。这是已知的安全问题。 此时您确实应该考虑升级到 .NET Core 8 或 9


也就是说,.NET core 运行时和 SDK 不再安装在 Azure Pipelines 代理中,您需要将它们安装为管道的一部分。

您可以获取 Azure Pipelines 来构建旧版本的 .NET core,您必须首先使用

Use .NET core
任务安装 SDK,并指定所需的版本:

Pipeline added the Use Net Core task and set version to 3.1

© www.soinside.com 2019 - 2024. All rights reserved.