More than one package matched with specified pattern: %s. Please restrain the search pattern

Viewed 903

I was trying to create a release pipeline in Azure DevOps. All part works fine but getting error in IIS Web Deploy.

More than one package matched with specified pattern: %s. Please restrain the search pattern.

Error

Here is the task for Web Deploy.

IIS Web Deploy

I have the yml as:

trigger:
- main

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: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    zipAfterPublish: true
    arguments: '--output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
  inputs:
   pathToPublish: $(Build.ArtifactStagingDirectory)
   artifactName: AspNetCoreExample
1 Answers

More than one package matched with specified pattern: %s. Please restrain the search pattern

The zip files are came from your build pipeline. if you need only the .zip so configure your build pipeline publish artifacts task to take only this.

However, you have publish your project by the task VSBuild and DotNetCoreCLI:publish. In this case, you will have one more .zip file in your artifact, which will cause that issue.

- 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: DotNetCoreCLI@2  #Move this task.
  inputs:
    command: 'publish'
    publishWebProjects: true
    zipAfterPublish: true
    arguments: '--output $(build.artifactstagingdirectory)'

To resolve this issue, please move the task - task: DotNetCoreCLI@2 and make sure you have only one package in your .zip file.

Related