将文件夹工件部署到Azure应用服务时出错

时间:2020-10-19 10:33:37

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

我正在使用Azure Dev Ops运行我的构建和发布管道。我有一个生成脚本,该脚本将Web代码发布到工件文件夹(使用.NET SDK项目),而我只需要将此代码推送到Azure应用服务中即可。我尝试了发布管道中的“ Azure应用程序服务部署”和“将代码部署到应用程序服务”任务,给它来自我的Azure实例的发布设置文件,并指向我的代码所在的文件夹(因为它说需要zip或文件夹)。但是,在此步骤的控制台上,我收到一条错误消息“不存在这种部署方法。”

我能够通过FTP进行推送,但我想了解为什么应用服务发布无法正常工作,因为将来可能需要使用某些选项(例如部署插槽)。在这种情况下,使用Azure资源管理器连接会更好吗?还是我的构建工件毕竟需要压缩?如果必须将其压缩为Web部署,那么在解决方案构建后是否需要执行此步骤,因为我必须先将文件复制到工件文件夹中以进行转换,所以我不能只进行全面的Web构建/ zip

1 个答案:

答案 0 :(得分:1)

我看不到您的管道的详细信息,因此我将与您分享。我正在部署zip包:

enter image description here

Package or folder对话框中,我有:

enter image description here

我在管道中使用YAML,但是如果您想在经典管道中使用类似的内容,这很容易理解和遵循:

trigger: none
pr: none

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'
  projectDirectory: 'app-service-deployment-to-slot-with-preview\hadar'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'
  workingDirectory: $(projectDirectory)

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish
    publishWebProjects: false
    projects: '$(projectDirectory)\hadar.csproj'
    arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: true

- task: CopyFiles@2
  displayName: 'Copy configuration settings checks'
  inputs:
    contents: app-service-deployment-to-slot-with-preview\scripts\**
    targetFolder: '$(Build.ArtifactStagingDirectory)\scripts'
    flattenFolders: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifacts'