Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS NuGet pack exclude test projects

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?

like image 661
Edward Wilson Avatar asked Apr 18 '16 11:04

Edward Wilson


People also ask

What does Dotnetcorecli 2 do?

Build, test, package, or publish a dotnet application, or run a custom dotnet command. Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.

What is NuGet restore in TFS build?

We use most is Nuget restore in TFS build definition. To promote a cleaner development environment and to reduce repository size, NuGet Package Restore installs all a project's dependencies as listed in either the project file or packages.config .

How do I add NuGet package to Azure pipeline?

Navigate to your classic pipeline definition, and then select Edit. Select + to add a new task. Search for NuGet, and then select Add to add the task to your pipeline. Name your task and select Restore from the Command.


2 Answers

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

like image 108
Matt Cooper Avatar answered Oct 15 '22 23:10

Matt Cooper


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.

like image 7
Chrono Avatar answered Oct 15 '22 22:10

Chrono