One of the available pipeline tasks in Azure DevOps is the dotnet core CLI task. Through this task you can execute the available command line options that dotnet offers.
One of those command line options is ‘dotnet pack’ that allows you to create nuget packages from either csproj or nuspec files.
You can specify where the task should search for these files by configuring the ‘Path to csproj or nuspec file(s) to pack’ option. However I noticed that this option didn’t work as expected. I tried to exclude some files but that didn’t work.
I found out that the suggestion next to the option was wrong. The pattern described was incorrect. The documentation mentions that you should use ‘-:’ to exclude files and folder. This is wrong, instead you should use a ‘!’:
Wrong pattern:
**/*.csproj;-:**/*.Tests.csproj
Correct pattern:
**/*.csproj;!**/*.Tests.csproj