Berikut ini adalah yaml saya:

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:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'myWebsiteName'

- task: AzureWebApp@1
  inputs:
    azureSubscription: 'mySubscription'
    appType: 'webApp'
    appName: 'mySiteName'
    package: '$(System.DefaultWorkingDirectory)/**/*.zip'
    deploymentMethod: 'auto'
##[error]Error: No package found with specified pattern: D:\a\1\s\**\*.zip<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

Saya bahkan sudah mencoba mengubah $(System.DefaultWorkingDirectory) ke $(Build.ArtifactStagingDirectory) dalam tugas AzureWebApp untuk tidak berhasil.

-1
Ali Bdeir 2 April 2021, 22:27

1 menjawab

Jawaban Terbaik

Dalam situasi Anda saat ini, saya memiliki beberapa saran dapat membantu Anda menyelesaikan masalah ini:

  1. Silakan periksa opsi 'Aktifkan Sistem Diagnostik Sistem saat Anda menjalankan pipa Anda lalu periksa tugas Build Anda dan periksa apakah file zip telah berhasil dibuat dan temukan folder file zip.
  2. Silakan buka halaman Pipeline UI dan periksa apakah Anda dapat menemukan file artefak pada halaman, pastikan file ZIP telah dimasukkan.

Jika Anda dapat menemukan file zip di artefak Anda. Maka kita dapat memodifikasi file YAML Anda seperti ini:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
stages:
  - stage: generate
    jobs:
      - job: Job_1
        displayName: job_Create_Zip
        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:PackageLocation="$(build.artifactStagingDirectory)"'
            platform: '$(buildPlatform)'
            configuration: '$(buildConfiguration)'

        - task: VSTest@2
          inputs:
            platform: '$(buildPlatform)'
            configuration: '$(buildConfiguration)'

        - task: PublishBuildArtifacts@1
          inputs:
            pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
            artifactName: 'myWebsiteName'
  - stage: 
    jobs:
      - job: Job_2
        displayName: Deploy_zip 
        steps:
        - task: DownloadPipelineArtifact@2
          inputs:
            buildType: 'current'
            artifactName: 'myWebsiteName'
            itemPattern: '**/*.zip'
            targetPath: '$(System.DefaultWorkingDirectory)'
        - task: AzureWebApp@1
          inputs:
            azureSubscription: 'mySubscription'
            appType: 'webApp'
            appName: 'mySiteName'
            package: '$(System.DefaultWorkingDirectory)/**/*.zip'
            deploymentMethod: 'auto'


   
1
Yujun Ding-MSFT 5 April 2021, 02:16