Hey all, so today I wanted to use the new (finally) feature of pushing nuget packages to nuget feeds inside of Visual Studio Online's build environment. Which is turning out to be really awesome by the way.

Anyways, I'm doing a vNext project and it creates 2 nuget packages *.nupkg. I create a new Nuget Publish task and it set the default. First, it won't work correctly, it'll try and upload some downloaded nuget packages. Lame. So we need to change the default of **\*.nupkg to **\artifacts\**\*.nupkg.

This will now filter down the list to the actual nuget packages to be pushed. However, there are 2 packages for each one, one containing symbols, and one that does not. The internal naming and versions are identical in each. And because of that things will get odd. Like not being able to see your non-symbol nuget package. Or errors stating a version of that package is already uploaded, maybe something about not event chuck norris can do this. So. I needed to set an exclude filter. Supposedly the file matching is using minimatch. But almost nothing that minimatch supports works, including the | (pipe/or). You get all sorts of errors when you try different formats that should theoretically work. After a bit of digging in the nuget publish task I saw it calls a Find-Files powershell command. Which is not in powershell by default. So, dug around some more, it's loaded from a module. Microsoft.TeamFoundation.DistributedTask.Task.Common. Decompiling that using ILSpy, I could see the find-file command and was able to see what it does. One very undocumented feature is that you can add multiple filters into the same one seperated by a ; (semicolon). There is also a prefix you can put on the front of the filter to designate whether it's an include, or exclude. Prepend the filter with a +: to explicitly set it to an include, or use a -: to set it as an exclude.

Just an FYI, the nuget publish task automatically adds the working path to the front of the filter. So don't put a +: or -: on the first filter.

Ok, so that was the down and dirty. A quick example.

NuGet files created:

src\artifacts\bin\Vecc.Settings\Release\Vecc.Settings.1.0.3.nupkg
src\artifacts\bin\Vecc.Settings\Release\Vecc.Settings.1.0.3.symbols.nupkg
  • Filter for selecting correct nupkgs **\artifacts\**\*.nupkg
  • Filter for selecting non-symbol packages **\artifacts\**\*.nupkg;-:**\artifacts\**\*Symbols*.nupkg
  • Filter for selecting symbol packages **\artifacts\**\*Symbols*.nupkg

Hopefully this helps someone else in doing this seemingly easy task.