Azure CI/CD:本地部署失败

Azure CI/CD: On-Premise deployment failing

我正在尝试将我的代码从 Azure 部署到我的本地计算机。我遵循的步骤:

  1. 已创建部署组
  2. 运行 在我的机器上注册脚本(在 C:\azagent 中成功创建的文件夹)
  3. 已创建管道。

对于管道,生成的 YAML 是:

# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  
steps:
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: 'a31f9237-4431-41f2-b1a9-4370c7dc4828/a3a86133-79b3-437a-bc19-9665a420de4e'
- task: VSBuild@1
  inputs:
    solution: '**\*.sln'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    restoreNugetPackages: true

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(build.sourcesdirectory)'
    Contents: '**\bin$(BuildConfiguration)\**'
    TargetFolder: '$(build.artifactstagingdirectory)'
    CleanTargetFolder: true
    OverWrite: true
    
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

当我 运行 管道时,它没有给出任何错误,但在发布部分我得到一个错误:

我使用的解决方案有多个项目。我需要在我的机器上部署三个项目。这是我第一次使用 Azure DevOps,我对错误一无所知。在线文章主要是解释云部署,我找不到太多关于内部部署的文章。简而言之,我的要求是每当我将任何更改推送到 master 分支时,从我的 repo 部署三个项目到我的本地机器上。是否有任何分步指南来实现相同目标?我在设置中错过了什么步骤?非常感谢任何帮助。

根据报错信息的描述,首先需要检查是否选择了对应的build pipeline作为release artifact source

然后您可以检查下载的工件路径是否与IIS web 应用程序部署任务的包(Package or Folder)的文件路径一致。

System.DefaultWorkingDirectory :在发布部署期间将工件下载到的目录。如果需要将工件下载到代理程序,则在每次部署之前清除该目录。与 Agent.ReleaseDirectory 和 System.ArtifactsDirectory 相同。 示例:C:\agent\_work\r1\a

详情请参考predefined variables文档

my requirement is to deploy three projects from my repo on my local machine whenever I push any changes to master branch.Is there any step by step guide to achieve the same?

要实现这一点,在 yaml 构建管道中,您需要设置 CI trigger:持续集成 (CI) 触发器会导致管道 运行 每当您将更新推送到指定分支。

在发布管道中,您需要将构建管道设置为发布artifact source, and then enable Continuous deployment trigger:这会指示 Azure Pipelines 在检测到新工件可用时自动创建新版本。