James Ko
James Ko

Reputation: 34499

How to privately reference another project from a NuGet package?

I'm looking for a way to 'privately' reference an MSBuild project so that it won't be shown to the user of the NuGet package. For example, suppose I have two libraries, LibFoo and LibBar. They're organized under a single solution, like this:

Foobar.sln
|
---- LibFoo.csproj
|
---- LibBar.csproj

Now, suppose LibFoo references LibBar. When I go to build LibFoo, LibBar is built as well. The resulting binaries are both included in LibFoo's output directory. When I nuget pack them and include everything in the directory as part of the NuGet package, LibBar's binaries are included as well.

Finally, when the end-user installs LibFoo, NuGet goes ahead and references everything in the package, including LibBar.

Is there any way to prevent this from happening?

Upvotes: 0

Views: 174

Answers (1)

Manuel Zelenka
Manuel Zelenka

Reputation: 1634

I guess it is not possible to exclude a dll directly but you can specify explicitly which assemblies should be referenced. This in turn does what you want since all not specified assemblies won't be added as a reference.

Have a look at this section of the nuget docs.

Upvotes: 2

Related Questions