【问题标题】:getting error in AzureDevOps Release pipeline running due to artifact由于工件在运行的 Azure DevOps 发布管道中出现错误
【发布时间】:2022-11-30 14:59:49
【问题描述】:

您好,我遇到了问题。假设我有一个简单的 Web 应用程序并将其推送到 Azure Repos。现在,我使用 yaml 设置构建管道,然后设置发布管道,该管道需要来自构建管道的工件。所以我正在使用 PublishPipelineArtifact@1。构建管道运行良好,但我的发布管道失败并出现错误 Deployment of msBuild generated package is not supported。更改包格式或使用 Azure 应用服务部署任务。 D:\a\r1\a_ReleasePipelines\drop\WebApp.zip。 那么如何以正确的命名顺序提供发布管道所需的工件呢?

下面是我用于构建管道的 yaml

`

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(build.artifactStagingDirectory)'
    publishLocation: 'pipeline'


` 接下来,我将使用空作业设置一个简单的发布管道,并在 Add Artifact 中提供项目名称和源代码。

【问题讨论】:

    标签: azure-devops azure-pipelines azure-pipelines-release-pipeline


    【解决方案1】:

    根据 YAML 中的 MS 构建参数,它适用于 Web 部署方法。

    如果您想将方法更改为 Zip 部署,可以按照此官方链接更改参数:https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-rm-web-app-deployment-v4?view=azure-pipelines&viewFallbackFrom=azure-devops#error-publish-using-zip-deploy-option-is-not-supported-for-msbuild-package-type

    推荐发布构建工件:https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-build-artifacts-v1?view=azure-pipelines&viewFallbackFrom=azure-devops

    这是一个示例,

    steps:
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: drop'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
      condition: succeededOrFailed()
    

    在您的发布管道中,您需要从构建中指定管道工件:

    并使用 Azure App Service Deploy 任务进行部署。

    构建管道示例:

    发布管道示例:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-01
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 2020-12-23
      • 2020-11-26
      • 1970-01-01
      • 2021-10-08
      相关资源
      最近更新 更多