aeje
aeje

Reputation: 279

dotnet pack command does not generate .nuget packages for tests and spec projects?

We have a solution with mutiple projects that includes projects with unit and spec tests. When we run dotnet pack command on the solution the packages donot get generated for the unit and spec test projects. This is a good thing that it excludes test prjoects. Just wanted to understand how does not dotnet pack command exclude projects from being packaged.

On experimenting i noticed that when i added project dependency to xunit and xnit.runner.visualstudio on any project then dotnet pack doesn't generate packages for that project.

dotnet pack C:\Projects\SysScore_Integration\SysScore\SysScore.sln --output C:\Projects\LocalNuGet\ /p:PackageVersion=1.0.1.8

Upvotes: 11

Views: 2562

Answers (1)

Tom W
Tom W

Reputation: 5413

Adding the property <IsPackable>true</IsPackable> to the .csproj file fixes this.

Apparently having a reference to xUnit is all that is required to make a project be considered a "test project" - even if the project contains no tests. This interferes with the situation where for example one is writing a reusable test framework which uses or extends the test framework attributes. I would expect dotnet pack to at least print a warning explaining why the command is being ignored, but whoever implemented this clearly did not agree.

Upvotes: 25

Related Questions