Why do we need a package manager like Nuget?

I know that a package manager such as NuGet helps us when we want to use third-party components.

From the Nuget Codeplex Page:

NuGet is a free open source package management system for the .NET platform, aimed at simplifying the process of incorporating third-party libraries into a .NET application during development.

There are many useful third-party open source libraries for the .NET platform, but for those who are not familiar with the OSS ecosystem, it can be a pain to pull these libraries into the project.

Let's take ELMAH as an example. Its a subtle error-logging utility that does not depend on other libraries, but is still a problem for integration into the project. These are the following steps:

Find ELMAH Download the correct zip package. "Unblock" the package. Verify its hash against the one provided by the hosting environment. Unzip the package contents into a specific location in the solution. Add an assembly reference to the assembly. Update web.config with the correct settings which a developer needs to search for. 

And this is for a library that has no dependencies. Imagine doing this for NHibernate.Linq, which has several dependencies, each of which needs similar steps. We can do much better!

NuGet automates all these common and tedious tasks for a package as well as its dependencies. It fixes almost all problems incorporating a third-party open source library into source tree projects

these steps are simple tasks that we perform when we want to set up a project. its only to automate the addition of third-party components and reduce the likelihood of errors in the configuration files? or does he have much more responsibilities !?

+6
source share
2 answers

This value is hidden in the open: a package manager such as NuGet helps you deal with software dependencies using automation. Many people assume that it is intended only for open source or third-party components, but you can also use it for your own internal packages.

The great thing about NuGet (to name a few benefits):

  • NuGet encourages component reuse because you implicitly rely on actual β€œreleases” (even in the case of a pre-release) instead of branching sources
  • you can get rid of binaries that inflate your VCS repositories (package recovery function)
  • it makes package developers think about how the package will be used, and does they leave work with configuring the component during package installation (who knows better how to configure the package than the creators of the package?). As an example, consider the ELMAH example.
  • Automatically creating and publishing packages in the package repository is a form of continuous delivery (for software components). OctopusDeploy even takes this even further and allows you to pack all the web sites ready for deployment.
  • NuGet encourages and sometimes leads you to follow some ALM best practices. For instance. the package has a version, so you need to think about your version control strategy (for example, SemVer.org).
  • NuGet integrates with SymbolSource.org (which also has a Community version for customization): this makes it easy to debug released packages without having to send this information all the time
  • having one or more package repositories makes it easier for an organization to maintain a dependency matrix or even create an inventory of OSS licenses that are used by several projects.
  • NuGet notifies you of available package updates.
  • Creating packages makes people think about component architecture (all dependencies must also be packaged).
  • Package dependencies are automatically resolved (so you cannot forget them)
  • NuGet is smart enough to add assembly binding redirects if necessary

The list above is not exhaustive, but I hope that I have covered the key benefits in this answer. I am sure there are more of them.

Cheers, Xavier

+17
source

The reason for using NuGet is that you do not need to send all the libraries of your project, reducing the size of the project. Using NuGet Power Tools, specifying the package version in the Packages.config file, you can download all the necessary libraries when you first start the project.

Live Exapmle: Reduces project size when deploying a project. If the solution has 500 MB of code and 200 MB of packages, then an additional 200 MB of project download cost each time. Instead of loading the concrete dll, we just need to set their link in the packages.config file.

+3
source

All Articles