Magni Hansen
Magni Hansen

Reputation: 102

Copy dependency assemblies into nuget package

I got a VS 2019 solution with many .Net Standard 2.0 projects. My main project has a project dependency to another project that has a dependency to a Dapper assembly. After compiling the main project into a NuGet package, the package hasn't got the Dapper dependency. How can I include the Dapper assembly into the NuGet package ?

Upvotes: 0

Views: 332

Answers (1)

Mr Qian
Mr Qian

Reputation: 23848

Copy dependency assemblies into nuget package

When you pack your main project, it will make another project as a nuget package because the main project references another project. You should note that dotnet pack will see another project as a nuget package but you did not pack another project additionally.

So it will miss another project on the package source and the dependency Dapper exists under another project.

It is not in the dependency of the main project but in the dependency package of another project.

Suggestion

==========================================================

1) You do not worry too much about that. You should also pack another project as a nuget package and then put it into the nuget package source.

Like this:

enter image description here

enter image description here

enter image description here

Although the dependency Dapper does not show on the main project, it shows under the dependency package. And it is installed into the project along with the dependency project.

=====================================================

Please note that:

Before you install any version of the package, you should first clean nuget caches first or delete the cache packages folder under C:\Users\xxx(current user)\.nuget

enter image description here

=========================================================

2) If you still want to see the dependency Dapper under the main project, you should also install Dapper nuget package into the main project.

Then pack it and you can see the dependency Dapper in it.

=========================================================

Besides, if you do not want the referenced project to become a dependency nuget package, but just an assembly dll, you could refer to this link's solution.

Upvotes: 1

Related Questions