8

I am using VSTS vNext build system to build a C# solution. Below you can see the settings for the NuGet Packager. The path to nuspec files is set to reference the .csproj files.

enter image description here

However this includes all .csproj files; I need to exclude test projects. Ignoring 'Core.Test.csproj' but still packaging 'Core.csproj'.

I have tried '*.csproj;-:!*test.csproj' and other combinations but have had no luck figuring this out! Does anyone know how the pattern matching works for vNext build?

Community
  • 1
  • 1
Edward Wilson
  • 436
  • 1
  • 5
  • 8

2 Answers2

14

**\*.csproj;-:**\*test.csproj should do it (no exclaimation point needed). If not, we may have a bug, and you should file it on GitHub.

Matt Cooper
  • 866
  • 8
  • 15
  • Are you aware of being able to do more than one exclude? e.g. `**/*.csproj;-:**/*.Tests.csproj;-:**/*.ConsoleApp.csproj` – chris31389 Nov 17 '17 at 10:52
  • I'm finding that it doesn't :s should I raise it as an issue on GitHub? – chris31389 Nov 17 '17 at 11:47
  • Yes. I'm not on that team anymore but I'll forward this to someone who is. – Matt Cooper Nov 17 '17 at 11:52
  • 4
    The exclude pattern has changed. From the docs (https://docs.microsoft.com/en-us/vsts/build-release/tasks/package/nuget#pack-nuget-packages): Use file matching patterns to publish multiple packages. Note that these patterns were updated in version 2 of the NuGet task; if you have a pattern that contains -:, use ! instead. – Alex Mullans Nov 17 '17 at 15:41
6

The latest version (2.x) of the NuGet task in VSTS and TFS 2018 uses a different pattern for excluding packages. Now you use ! instead of -:.

So **\*.csproj;-:**\*.Test.csproj changes to **\*.csproj;!**\*.Test.csproj.

Full pattern matching documentation can be found here.

Chrono
  • 1,293
  • 1
  • 14
  • 28