Azure DevOps pipeline release Error: No package found with specified pattern: D:\a\r1\a\**\*.zip

Azure DevopsAzure PipelinesAzure Pipelines-Release-Pipeline

Azure Devops Problem Overview


I have an ASP.NET Core project in Azure DevOps repository and it gets built OK using the DevOps build pipeline. However, the release over that builds always fails with this error:

> Error: No package found with specified pattern: D:\a\r1\a***.zip

I've already checked out this and this Q/As, but cannot figure out the solution.

Here is my azure.pipelines.yml file:

pool:
  vmImage: 'vs2017-win2016'

variables:
  buildConfiguration: 'Release'

steps:
  - script: dotnet build ".\src\MyProject.sln" --configuration $(buildConfiguration)
    displayName: 'dotnet build $(buildConfiguration)'
  - script: dotnet publish ".\src\MyProject.sln" --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)
     displayName: 'dotnet publish $(buildConfiguration)'
  - task: PublishBuildArtifacts@1
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'drop' 
    publishLocation: 'Container'

More details

Release pipeline error: Azure DevOps Release Pipeline Error

Logs

Initialize job:

2018-11-02T05:31:14.7337716Z ##[section]Starting: Initialize job
2018-11-02T05:31:14.7338264Z Current agent version: '2.141.1'
2018-11-02T05:31:14.7365208Z Prepare release directory.
2018-11-02T05:31:14.7379296Z ReleaseId=4, TeamProjectId=ea66a316-xxxx-xxxx-xxxx-866fc594b83f, ReleaseDefinitionName=New release pipeline
2018-11-02T05:31:14.7461870Z Release folder: D:\a\r1\a
2018-11-02T05:31:14.7620235Z Environment variables available are below.  Note that these environment variables can be referred to in the task (in the ReleaseDefinition) by replacing "_" with "." e.g. AGENT_NAME environment variable can be referenced using Agent.Name in the ReleaseDefinition: 
            [AGENT_HOMEDIRECTORY] --> [C:\agents\2.141.1]
            [AGENT_ID] --> [2]
            [AGENT_JOBNAME] --> [Release]
            [AGENT_MACHINENAME] --> [factoryvm-az50]
            [AGENT_NAME] --> [Hosted Agent]
            [AGENT_OS] --> [Windows_NT]
            [AGENT_OSARCHITECTURE] --> [X64]
            [AGENT_RELEASEDIRECTORY] --> [D:\a\r1\a]
            [AGENT_ROOTDIRECTORY] --> [D:\a]
            [AGENT_SERVEROMDIRECTORY] --> [C:\agents\2.141.1\externals\vstsom]
            [AGENT_TEMPDIRECTORY] --> [D:\a\_temp]
            [AGENT_TOOLSDIRECTORY] --> [C:/hostedtoolcache/windows]
            [AGENT_VERSION] --> [2.141.1]
            [AGENT_WORKFOLDER] --> [D:\a]
            [AZURE_HTTP_USER_AGENT] --> [VSTS_70c99791-xxxx-xxxx-xxxx-5af143aa8244_release_1_4_4_2]
            [BUILD_BUILDID] --> [25]
            [BUILD_BUILDNUMBER] --> [20181102.1]
            [BUILD_BUILDURI] --> [vstfs:///Build/Build/25]
            [BUILD_DEFINITIONID] --> [1]
            [BUILD_DEFINITIONNAME] --> [MyProjectName]
            [BUILD_PROJECTID] --> [ea66a316-xxxx-xxxx-xxxx-866fc594b83f]
            [BUILD_PROJECTNAME] --> [MyProjectName]
            [BUILD_REPOSITORY_ID] --> [38420003-xxxx-xxxx-xxxx-6fd304fd324c]
            [BUILD_REPOSITORY_NAME] --> [MyProjectName]
            [BUILD_REPOSITORY_PROVIDER] --> [TfsGit]
            [BUILD_REQUESTEDFOR] --> [MyUserName]
            [BUILD_REQUESTEDFORID] --> [b08e40ca-xxxx-xxxx-xxxx-2b6fc6e350f8]
            [BUILD_SOURCEBRANCH] --> [refs/heads/master]
            [BUILD_SOURCEBRANCHNAME] --> [master]
            [BUILD_SOURCEVERSION] --> [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
            [BUILD_TYPE] --> [Build]
            [MSDEPLOY_HTTP_USER_AGENT] --> [VSTS_70c99791-xxxx-xxxx-xxxx-5af143aa8244_release_1_4_4_2]
            [PARAMETERS_CONNECTEDSERVICENAME] --> [9d9a15a6-xxxx-xxxx-xxxx-2cb822e6a67e]
            [PARAMETERS_DOCKERNAMESPACE] --> []
            [PARAMETERS_DOCKERREPOSITORY] --> []
            [PARAMETERS_IMAGESOURCE] --> [Registry]
            [PARAMETERS_RUNTIMESTACK] --> []
            [PARAMETERS_WEBAPPKIND] --> [app]
            [PARAMETERS_WEBAPPNAME] --> [myprojectname]
            [RELEASE_ARTIFACTS_DROP_BUILDID] --> [25]
            [RELEASE_ARTIFACTS_DROP_BUILDNUMBER] --> [20181102.1]
            [RELEASE_ARTIFACTS_DROP_BUILDURI] --> [vstfs:///Build/Build/25]
            [RELEASE_ARTIFACTS_DROP_DEFINITIONID] --> [1]
            [RELEASE_ARTIFACTS_DROP_DEFINITIONNAME] --> [myprojectname]
            [RELEASE_ARTIFACTS_DROP_PROJECTID] --> [ea66a316-xxxx-xxxx-xxxx-866fc594b83f]
            [RELEASE_ARTIFACTS_DROP_PROJECTNAME] --> [MyProjectName]
            [RELEASE_ARTIFACTS_DROP_REPOSITORY_ID] --> [38420003-xxxx-xxxx-xxxx-6fd304fd324c]
            [RELEASE_ARTIFACTS_DROP_REPOSITORY_NAME] --> [MyProjectName]
            [RELEASE_ARTIFACTS_DROP_REPOSITORY_PROVIDER] --> [TfsGit]
            [RELEASE_ARTIFACTS_DROP_REQUESTEDFOR] --> [MyUserName]
            [RELEASE_ARTIFACTS_DROP_REQUESTEDFORID] --> [b08e40ca-xxxx-xxxx-xxxx-2b6fc6e350f8]
            [RELEASE_ARTIFACTS_DROP_SOURCEBRANCH] --> [refs/heads/master]
            [RELEASE_ARTIFACTS_DROP_SOURCEBRANCHNAME] --> [master]
            [RELEASE_ARTIFACTS_DROP_SOURCEVERSION] --> [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
            [RELEASE_ARTIFACTS_DROP_TYPE] --> [Build]
            [RELEASE_ATTEMPTNUMBER] --> [2]
            [RELEASE_DEFINITIONENVIRONMENTID] --> [1]
            [RELEASE_DEFINITIONID] --> [1]
            [RELEASE_DEFINITIONNAME] --> [New release pipeline]
            [RELEASE_DEPLOYMENT_REQUESTEDFOR] --> [MyUserName]
            [RELEASE_DEPLOYMENT_REQUESTEDFOREMAIL] --> [[email protected]]
            [RELEASE_DEPLOYMENT_REQUESTEDFORID] --> [b08e40ca-xxxx-xxxx-xxxx-2b6fc6e350f8]
            [RELEASE_DEPLOYMENT_STARTTIME] --> [2018-11-02 05:29:41Z]
            [RELEASE_DEPLOYMENTID] --> [8]
            [RELEASE_DEPLOYPHASEID] --> [8]
            [RELEASE_ENVIRONMENTID] --> [4]
            [RELEASE_ENVIRONMENTNAME] --> [Stage 1]
            [RELEASE_ENVIRONMENTS_STAGE_1_STATUS] --> [InProgress]
            [RELEASE_ENVIRONMENTURI] --> [vstfs:///ReleaseManagement/Environment/4]
            [RELEASE_PRIMARYARTIFACTSOURCEALIAS] --> [drop]
            [RELEASE_REASON] --> [Manual]
            [RELEASE_RELEASEDESCRIPTION] --> [Trying manually]
            [RELEASE_RELEASEID] --> [4]
            [RELEASE_RELEASENAME] --> [Release-4]
            [RELEASE_RELEASEURI] --> [vstfs:///ReleaseManagement/Release/4]
            [RELEASE_RELEASEWEBURL] --> [https://dev.azure.com/mycompany/ea66a316-xxxx-xxxx-xxxx-866fc594b83f/_release?releaseId=4&_a=release-summary]
            [RELEASE_REQUESTEDFOR] --> [MyUserName]
            [RELEASE_REQUESTEDFOREMAIL] --> [[email protected]]
            [RELEASE_REQUESTEDFORID] --> [b08e40ca-xxxx-xxxx-xxxx-2b6fc6e350f8]
            [RELEASE_SKIPARTIFACTSDOWNLOAD] --> [False]
            [RELEASE_TRIGGERINGARTIFACT_ALIAS] --> []
            [REQUESTEDFORID] --> [b08e40ca-xxxx-xxxx-xxxx-2b6fc6e350f8]
            [SYSTEM] --> [release]
            [SYSTEM_ARTIFACTSDIRECTORY] --> [D:\a\r1\a]
            [SYSTEM_COLLECTIONID] --> [70c99791-xxxx-xxxx-xxxx-5af143aa8244]
            [SYSTEM_CULTURE] --> [en-US]
            [SYSTEM_DEFAULTWORKINGDIRECTORY] --> [D:\a\r1\a]
            [SYSTEM_ENABLEACCESSTOKEN] --> [False]
            [SYSTEM_HOSTTYPE] --> [release]
            [SYSTEM_JOBID] --> [22af3160-xxxx-xxxx-xxxx-2001a5e5d480]
            [SYSTEM_JOBPARALLELISMTAG] --> [Private]
            [SYSTEM_JOBPOSITIONINPHASE] --> [1]
            [SYSTEM_PARALLELEXECUTIONTYPE] --> [None]
            [SYSTEM_PLANID] --> [12163963-xxxx-xxxx-xxxx-dff7b6858fe8]
            [SYSTEM_SERVERTYPE] --> [Hosted]
            [SYSTEM_TASKDEFINITIONSURI] --> [https://dev.azure.com/mycompany/]
            [SYSTEM_TEAMFOUNDATIONCOLLECTIONURI] --> [https://dev.azure.com/mycompany/]
            [SYSTEM_TEAMFOUNDATIONSERVERURI] --> [https://vsrm.dev.azure.com/mycompany/]
            [SYSTEM_TEAMPROJECT] --> [MyProjectName]
            [SYSTEM_TEAMPROJECTID] --> [ea66a316-xxxx-xxxx-xxxx-866fc594b83f]
            [SYSTEM_TIMELINEID] --> [12163963-xxxx-xxxx-xxxx-dff7b6858fe8]
            [SYSTEM_TOTALJOBSINPHASE] --> [1]
            [SYSTEM_WORKFOLDER] --> [D:\a]
2018-11-02T05:31:15.2649945Z Download all required tasks.
2018-11-02T05:31:15.2814886Z Downloading task: AzureRmWebAppDeployment
2018-11-02T05:31:17.1807839Z ##[section]Finishing: Initialize job

Download Artifacts:

2018-11-02T05:31:17.2269286Z ##[section]Starting: Download Artifacts
2018-11-02T05:31:17.2382502Z Creating artifacts directory: D:\a\r1\a
2018-11-02T05:31:17.2399560Z Created artifacts directory: D:\a\r1\a
2018-11-02T05:31:17.2399678Z Downloading artifact
2018-11-02T05:31:17.2414468Z Starting artifacts download...
2018-11-02T05:31:17.2445323Z Downloading linked artifact drop of type Build...
2018-11-02T05:31:17.2485179Z Ensuring artifact folder D:\a\r1\a\drop exists and is clean.
2018-11-02T05:31:17.2560775Z Preparing to get the list of available artifacts from build
2018-11-02T05:31:17.4683478Z Preparing to download artifact: drop
2018-11-02T05:31:17.4757997Z Artifact Type: ServerDrop
2018-11-02T05:31:17.4758675Z Downloading artifact from file container: #/2728848/drop to target: D:\a\r1\a\drop\drop
2018-11-02T05:31:17.4761540Z Parallel download limit: 4
2018-11-02T05:31:17.4761629Z Download buffer size: 8192
2018-11-02T05:31:17.5861772Z Caching items under 'drop' in the file container...
2018-11-02T05:31:17.6566410Z Caching complete. (70 ms)
2018-11-02T05:31:17.6722228Z Downloading file D:\a\r1\a\drop\drop\appsettings.Development.json
2018-11-02T05:31:17.6960764Z Downloading file D:\a\r1\a\drop\drop\appsettings.json
2018-11-02T05:31:17.6963293Z Downloading file D:\a\r1\a\drop\drop\dotnet-aspnet-codegenerator-design.dll
.
.
.
Lots of other JSON and DLL files.
.
.
.
2018-11-02T05:31:22.7080863Z Download complete.
2018-11-02T05:31:22.7086672Z 123 placed file(s): 122 downloaded, 1 empty
2018-11-02T05:31:22.7087329Z 29 MB downloaded at 5848 KB/sec. Download time: 00:00:05.0380618.
2018-11-02T05:31:22.7115052Z Downloaded linked artifact drop
2018-11-02T05:31:22.7115281Z Finished artifacts download
2018-11-02T05:31:22.7189498Z ##[section]Finishing: Download Artifacts

Deploy Azure App Service:

2018-11-02T05:31:22.7214141Z ##[section]Starting: Deploy Azure App Service
2018-11-02T05:31:22.7468470Z
==============================================================================
2018-11-02T05:31:22.7468805Z Task         : Azure App Service Deploy
2018-11-02T05:31:22.7468901Z Description  : Update Azure App Services on Windows, Web App on Linux with built-in images or Docker containers, ASP.NET, .NET Core, PHP, Python or Node.js based Web applications, Function Apps, Mobile Apps, API applications, Web Jobs using Web Deploy / Kudu REST APIs
2018-11-02T05:31:22.7469033Z Version      : 3.4.13
2018-11-02T05:31:22.7469089Z Author       : Microsoft Corporation
2018-11-02T05:31:22.7469173Z Help         : [More information](https://aka.ms/azurermwebdeployreadme)
2018-11-02T05:31:22.7469246Z
==============================================================================
2018-11-02T05:31:23.6141335Z Got connection details for Azure App Service:'myproject'
2018-11-02T05:31:27.9431753Z ##[error]Error: No package found with specified pattern: D:\a\r1\a\**\*.zip
2018-11-02T05:31:29.9576685Z Successfully added release annotation to the Application Insight : myproject
2018-11-02T05:31:33.0440055Z Successfully updated deployment History at https://xxxxxxxxx.scm.azurewebsites.net/api/deployments/4154xxxxxx957
2018-11-02T05:31:33.0615049Z ##[section]Finishing: Deploy Azure App Service

Azure Devops Solutions


Solution 1 - Azure Devops

I had the same problem and after googling around I found this answer

In summary, that answer says that you you need to go to your builds section and edit it. Edit Builds

At the very end of the .yaml file you need to add an additional line.

- task: PublishBuildArtifacts@1

Add line to .yaml file

Queue a new build and you should be good to go!

Solution 2 - Azure Devops

As every one has pointed this error is because the build task is not configured. You need to put the below YAML code at the last to make it work.

- task: PublishBuildArtifacts@1

You can see the error by going to this Azure tutorial , I have pointed to exact time line to avoid seeing the full video.

Happy learning coding.

Solution 3 - Azure Devops

For us, it was just the wrong path on the Deploy task for the "Package or Folder". It wasn't matching what we had on the Pipeline tab (as one of the artifacts): enter image description here

Solution 4 - Azure Devops

In my case I was deploying to the Azure App Service and I had to change the section packageForLinuxto use the path from PathToPublish by default it was System.DefaultWorkingDirectory

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Pay-As-You-Go ($(subscriptionId))'
    appType: 'webApp'
    WebAppName: 'webappname'
    deployToSlotOrASE: true
    ResourceGroupName: 'resourceGroupName'
    SlotName: 'production'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/*.zip'

Solution 5 - Azure Devops

I was getting the same error with sample Java code using Maven. For that, you need to also add CopyFiles task before PublishBuildArtifacts

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.11'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    goals: 'package'

- task: CopyFiles@2
  inputs:
    contents: '**/*.war'
    targetFolder: '$(build.artifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    artifactName: 'war'
    pathToPublish: '$(build.artifactStagingDirectory)'

Solution 6 - Azure Devops

ASP.NET Project:

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

Solution 7 - Azure Devops

This is happening because we haven't either published artifact or not referenced correctly

first in azure-pipelines.yml make this changes

- task: CopyFiles@2
      inputs:
        targetFolder: '$(Build.ArtifactStagingDirectory)' 
 
- task: PublishBuildArtifacts@1    
displayName: 'Publish Artifact: drop'
inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

this will copy files from repo to artifact and publish artifact called drop

after doing that run the pipeline

when it comes to release,

create release, add artifact

now go to task > click on 3 dots menu shown below to see what artifacts you have. select drop

You'll see dropdown as shown below, find the your artifact, in this case it will be drop Dropdown

then most importantly you'll need to resource (environment) if you haven't added yet go do that first,

Don't forget to save!!!

photo attached below for reference.

In order

Solution 8 - Azure Devops

You can also get this error if your Agent Selection (Agent Pool) selection in the Release->Stage->Phase 1 is not the same as in Pipeline->Phase 1. For example if you have an on-prem agent pool for the pipeline and Azure Pipelines agent pool for the release. An on-prem agent might have the agent_work folder on c: while Azure build agent might have it on d:, and even if the drives match there won't be any files to deploy as the agent machines are different.

Solution 9 - Azure Devops

In my case it wasn't finding the .zip because I had mistakenly selected the Repository as the Artifact instead of the Build in my Release Pipeline.

Screenshot of release pipeline artifact

Solution 10 - Azure Devops

I tried the following answers on here but i still got stuck with

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.

And i am using vmImage: 'windows-latest'

So what works for me is this:

- stage: deploy_dev
    displayName: 'Deploy Functions'
    jobs:
    - job: deploy1
        displayName: 'Deploy ${{ parameters.appName }} (${{ parameters.environment }})'
        pool:
        vmImage: 'windows-latest'
        steps:
        - task: NodeTool@0
            inputs:
            versionSpec: '10.x'
        - bash: |
                cd $appName
                npm install
            displayName: 'Install Dependencies'
            env:
            appName: ${{ parameters.appName }}
        - bash: |
                cd $appName
                npm run build
            displayName: 'Build Typescript'
            env:
            appName: ${{ parameters.appName }}
        - task: ArchiveFiles@2
            displayName: 'Compress App'
            inputs:
            rootFolderOrFile: '$(System.DefaultWorkingDirectory)/${{ parameters.appName }}'
            includeRootFolder: false
            archiveFile: '$(Build.ArtifactStagingDirectory)/${{ parameters.appName }}.zip'
        - task: PublishBuildArtifacts@1
            displayName: 'Publish Artifact'
            inputs:
            PathtoPublish: '$(Build.ArtifactStagingDirectory)'
            ArtifactName: 'drop'
            publishLocation: 'Container'
        - task: AzureFunctionApp@1
            displayName: 'Deploy ${{ parameters.appName }} to ${{ parameters.environment }}'
            inputs:
            azureSubscription: ${{ parameters.azureSubscriptionServiceConnectionName }}
            appType: functionAppLinux
            appName: ${{ parameters.appName }}-${{ parameters.environment }}
            package: $(Build.ArtifactStagingDirectory)/${{ parameters.appName }}.zip

## other stages, jobs and task

- stage: deploy_production
    displayName: 'Deploy App'
    jobs:
    - job: deploy1
        displayName: 'Deploying ${{ parameters.appName }}'
        pool:
        vmImage: 'windows-latest'
        steps:
        - download: current
            artifact: drop
        - task: AzureFunctionApp@1
            displayName: 'Deploy ${{ parameters.appName }}'
            inputs:
            azureSubscription: ${{ parameters.azureSubscriptionServiceConnectionName }}
            appType: functionAppLinux
            appName: ${{ parameters.appName }}-prd
            package: $(Pipeline.Workspace)/drop/${{ parameters.appName }}.zip

This solution works because of the download step and correct pathing

Solution 11 - Azure Devops

I ran into the same error, but i was skipping the download of artifacts. As soon as i enabled the download of artifacts, the deployment was successful.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTohidView Question on Stackoverflow
Solution 1 - Azure DevopsMatthew PetersonView Answer on Stackoverflow
Solution 2 - Azure DevopsShivprasad KoiralaView Answer on Stackoverflow
Solution 3 - Azure DevopsOJisBadView Answer on Stackoverflow
Solution 4 - Azure DevopsAmicableView Answer on Stackoverflow
Solution 5 - Azure Devopsuser3575337View Answer on Stackoverflow
Solution 6 - Azure DevopsR M Shahidul Islam ShahedView Answer on Stackoverflow
Solution 7 - Azure DevopsMilan PatelView Answer on Stackoverflow
Solution 8 - Azure DevopsSearch4SoundView Answer on Stackoverflow
Solution 9 - Azure Devopsadam0101View Answer on Stackoverflow
Solution 10 - Azure DevopsPhotonicView Answer on Stackoverflow
Solution 11 - Azure DevopsAnsibleUserView Answer on Stackoverflow