TFS include files and folders within the Delete Files Task

Viewed 207

I need to use the 'Delete files' task in a VNext build definition (TFS 2018). after 'Publish Artifact' task I am using the 'Delete File' task to delete all the files and folder in the drop folder but except the below ones and used the pattern like in Contents section

!bin/
!Views/
!Scripts/
!Content/
!Reports/
!Web.config

enter image description here

I found that we can use exclusion pattern, but it's not working. How can I make this work?

1 Answers

Delete Files task uses the minimatch patterns.

Q: What's a minimatch pattern? How does it work? A: See:

Thus, you could use !(bin), it will remove other folders except the bin folder.

For Web.config it should be !(Web.config)

If this still not work, you could use a copy file task to copy the folder as workaround. Details please refer Levi Lu's reply in this question: How to exclude some directories and files from deliting in Delete Files task

For multiple folder you can write

!(bin|views)
Related