I am new to nuget and trying got understand where I should define my dependencies. There is the section in my .nuspec file and then there is the list of dependencies in packages.config. What is used when?
The packages. config file is used in some project types to maintain the list of packages referenced by the project. This allows NuGet to easily restore the project's dependencies when the project is to be transported to a different machine, such as a build server, without all those packages.
Any time a package is installed or reinstalled, which includes being installed as part of a restore process, NuGet also installs any additional packages on which that first package depends. Those immediate dependencies might then also have dependencies on their own, which can continue to an arbitrary depth.
When building your assembly, NuGet uses the packages
section in the packages.config file to determine which NuGet packages to download.
When installing a package, NuGet uses the dependencies
section in .nuspec files to determine which additional NuGet packages to install. Of course, those additional NuGet packages can require their own additional NuGet packages.
When creating a .nuspec file, typically you include one dependency
entry for each package
entry you find in packages.config (skip package
entries with a developmentDependency="true"
attribute). But, if you want, you can also skip any package
entries that your assembly doesn't reference directly - the indirectly referenced packages should be covered by the dependency
entries in the packages that your project does reference directly. In practice, I have found it safer just to include all directly and indirectly referenced packages due to bugs in dependency lists of referenced packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With