Search code examples
azure-devopsazure-pipelines

ASP.NET Azure Web App Pipeline: No package found with specified pattern: D:\a\1\s\**\*.zip


The following is my YAML:

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.

I've even tried changing $(System.DefaultWorkingDirectory) to $(Build.ArtifactStagingDirectory) in the AzureWebApp task to no avail.


Solution

  • In your current situation, I have some suggestions might help you solve this issue:

    1. Please check the 'Enable system diagnostics' option when you run your pipeline then check your build task and check if the zip file has been created successfully and find the zip file folder.
    2. Please go to the pipeline UI page and check if you can find the artifact file on the page, also please make sure the zip file has been included.

    If you can find the zip file in your artifact. Then we can modify your yaml file like this:

    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'