Overview to NuGet package manager

A NuGet package is a .nupkg file that contains all the required components needed to reference an external library in a project. Typically, this component is one or more DLLs and the metadata describing the package. It can consist of other components, source code, and debug symbols, but this is rare.

When you install any of the Visual Studio 2017 workloads, by default it installs the support for NuGet along with the NuGet package manager tool, which you can find listed under the Individual components tab of the installer. If you uninstall it, all the dependent workloads will automatically get uninstalled from your system:

NuGet package manager comes in both console and GUI mode, integrated as part of the Visual Studio IDE. As GUI provides you with easier access to search, install, update, and uninstall a package, it is always preferable, and most of the time a developer interacts with it while using any library package through NuGet.

When you install a NuGet package, the following things happen:

  1. The package that you are trying to install gets downloaded in the packages folder under your solution directory.
  1. Any other NuGet packages that this package is dependent on also get downloaded automatically.
  2. The references to the package content (that is, the DLL references) automatically get added to the project.

To open NuGet package manager, click on Tools | NuGet Package Manager, and select Package Manager Console for the console window or Manage NuGet Packages for Solution... for the GUI window. This is shown in the following screenshot:

Alternatively, you can right-click on the project/solution to launch the NuGet Package Manager GUI from the context menu entry:

In the package manager window, search for the library that you want to install. It will give you a list of packages based on your search term. Select the one you want to install, select the suitable version, and click Install to continue:

It will pop up a dialog showing you the list of packages (including dependent packages) that it's going to install. Review the changes and click on OK to start the download process.

Once downloaded, it will add the assembly references to your project and add an entry to the packages.config file under your project directory:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.104.238