9

Is it true that for every dependency that a package has on some other library, that those libraries need to be resolved and installed as well?

For example, I created a package which uses NLog, Postsharp and WindowsAzure.Storage:

NuGet Dependencies

Do clients of my package now have to install these packages as well? Why is it not possible to include these dependency DLLs within the package?

Dave New
  • 38,496
  • 59
  • 215
  • 394

1 Answers1

15

When a consumer installs your nuget package, nuget will automatically resolve and install the dependent packages as well.

It is possible to include the dlls within the package but it is not recommended. Because one way or another they will have to have references to the dlls they need to use your package( in this case NLog, PostSharp and WindowsAzure.Storage). Its better that the consumer have controll over what libraries are installed.

Another benefit of having dependencies via nuget is that the consumer may decide to install a newer version of WindowsAzure.Storage library which he can do easily when you don't have the dll injected into the package. Otherwise you can get into some messy assemblies runtime errors.

You control what your package contains via nuspec file used to build the nuget package.

spottedmahn
  • 14,823
  • 13
  • 108
  • 178
Dorin
  • 2,482
  • 2
  • 22
  • 38
  • 10
    This answer is not very clear. The _nuspec_ file should contain the list of dependencies for your package. When the user installs your package, NuGet will look at the dependencies and will install those automatically if not already present. It will also install any dependencies of those dependencies, and so on. NOTE: The user does NOT have to manually install dependencies. See _Specifying Dependencies_ at http://docs.nuget.org/create/nuspec-reference – Kiliman Jan 30 '15 at 13:57
  • 1
    Kiliman, what was not clear in the answer? You did not add anything that wasn't already said in the answer. – Thomas Dec 16 '20 at 13:04