Search code examples
tfsmsbuildfnmatch

TFS - msbuild - fnmatch where filename doesn't contain character


I'm setting up a build in TFS. In the MSBuild step, it allows wildcards for the project name (like **/*.csproj). I'm assuming that it accepts fnmatch syntax like other fields in TFS.

I want to build all projects that don't contain the number "6" in the project name (because they are using .NET 6)

I would expect **/*!(6)*.csproj to work, but no dice.

I've tried a few different combinations but can't seem to get it to work. A few of the things I've tried:

  • **/*!(6)*.csproj
  • **/*([a-zA-Z0-57-9.]).csproj
  • **/[a-zA-Z0-57-9.]*.csproj

Solution

  • As of the time of writing this answer the current version of the Azure Pipelines MSBuild task is v1 and fnmatch syntax is not supported by the task.

    The Azure Pipelines DotNetCoreCLI task does support fnmatch syntax and MSBuild can be run via the dotnet command.

    Something like the following should work (but note that I have not tested this example):

    - task: DotNetCoreCLI@2
      displayName: 'dotnet msbuild'
      inputs:
        command: 'custom'
        custom: 'msbuild'
        projects: '**/*!(6)*.csproj'