0
votes

##[error]Error: More than one package matched with specified pattern: D:\a\r1\a***.zip. Please restrain the search pattern.

I am new to DevOp. I am not quite know how to configure the yaml in the pipeline. By default, there was a template created and i added archives and publish task inside like this.

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:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
 
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)'
    includeRootFolder: true
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
    
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

I guess there is something to do with

$(System.DefaultWorkingDirectory)/**/*.zip

Unsure what i need to configure.

2
Hi, is there any update for this issue? Feel free to let me know whether my anwser helps. - Jane Ma-MSFT

2 Answers

0
votes

##[error]Error: More than one package matched with specified pattern: D:\a\r1\a***.zip. Please restrain the search pattern.

This error message indicates that you have more than one .zip files in $(Build.ArtifactStagingDirectory).

In your YAML file, both

/p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip"

and

archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'

generate .zip file in $(Build.ArtifactStagingDirectory).

You need to specify which file you want to deploy, just like the following:

$(System.DefaultWorkingDirectory)/**/WebApp.zip
0
votes

In my case the .sln and .csproj files were in the same folder. I created a folder for the .csproj and moved the related files there.
It solved the problem.