NuGet package project references
I need to share a project from my solution as a NuGet, to provide base implementation types for my application's plugin system.
Let's call this project
BasePlugin
.
BasePlugin
has project dependencies that must be supplied with the produced NuGet package.
I was able to configure that; the built nuspec
file contains the required project references.
Done based on: https://dev.to/yerac/include-both-nuget-package-references-and-project-reference-dll-using-dotnet-pack-2d8p
However, projects referencing this NuGet cannot access types from the BasePlugin
dependencies.
How do I go about this? Not sure how to search for this.1 Reply
When you create a NuGet package from your project, it should automatically include information about its dependencies. This means that when another project uses your NuGet package, it should also have access to the types from your package's dependencies. For example, if your 'BasePlugin' package uses Newtonsoft.Json, projects that reference 'BasePlugin' should be able to use Newtonsoft.Json classes too. This happens because NuGet handles what's called "transitive dependencies" - it brings in not just your package, but also the packages your package depends on. If this isn't working as expected, it's worth checking your project file and NuGet package settings to ensure all dependencies are correctly specified and included.
Imagine this is your BasePlugin project (that gets built into a nuget package). It has a reference to Newtonsoft.Json:
Now, if you had a consumer that is using that package, that would also be able to use the Newtonsoft.Json package, because it's a transitive dependency.