Search code examples
tfstfsbuildglobminimatch

How can I filter with both NOT and OR in minimatch patterns?


We're using TFS 2017 and the Copy File build step to copy specific files of our build result to another directory. Specifically, we only want *.dll and *.exe copied, but no *.Tests.dll or *.resources.dll.

The build step support minimatch patterns to filter files, but I can't get it to apply BOTH filters.

The pattern looks like this:

bin\**\?(*.exe|*.dll)
bin\**\!(*.Tests.dll|*.resources.dll)

The folder content for example is:

bin\Yes.dll
bin\Yes.exe
bin\No.Tests.dll
bin\No\Some.resources.dll

It seems that the patterns are applied sequentially, so they both work individually, but not after another.

I tried something like

bin\**\?(*.exe|*.dll)!(*.Tests.dll|*.resources.dll)

But that didn't work either and filtered nothing. Can I combine these into a single filter somehow? The docs don't cover that case.


Solution

  • All right, seems you actually can just put the expressions directly after another, the filters just have to be more strict. This works, but I have still no clue why:

    bin\**\!(*.Tests.dll|*.resources.dll|*.pdb|*.xml|*.manifest)?(*.exe|*.dll)