Exclude folders files in ArchiveFiles task in Azure Devops

While running the ArchiveFiles task in Azure Devops pipeline if you want to exclude certian folders and files then you can follow the following stps:

Add a CopyFiles task just before the ArchiveFiles task. The tasks order will look like this:

  - task: CopyFiles@2
    displayName: "Copy files"
      SourceFolder: "$(System.DefaultWorkingDirectory)"
      Contents: |
      TargetFolder: "$(System.DefaultWorkingDirectory)/tmp"

  - task: ArchiveFiles@2
    displayName: "Prepare Zip"
      rootFolderOrFile: "$(System.DefaultWorkingDirectory)/tmp"
      includeRootFolder: false
      archiveType: zip
      archiveFile: $(System.DefaultWorkingDirectory)/YourZipName.zip
      replaceExistingArchive: true

In the above example the files with extenions md, yml and the folder git will be excluded from the zip.