Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packages.config vs Dependency section in .nuspec file

Tags:

nuget

msbuild

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?

like image 352
Patrick Avatar asked Feb 13 '15 13:02

Patrick


People also ask

What is a packages config file?

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.

Does NuGet package include dependencies?

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.


1 Answers

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.

like image 114
mheyman Avatar answered Sep 27 '22 18:09

mheyman