Learn Nuget Package Manager in 10 Minutes

Nuget is a package manager tool to download and configure reusable components in our projects. This tool is used when developing applications in Microsoft development platforms including .Net. Nuget package manager supports both GUI based and PowerShell command based tools to search and install packages into our project.

Nuget package manager relieves developers from doing the redundant tasks of downloading and configuring a re-usable component or package (both open source and Microsoft delivered) into the project. Nuget will also help developers to find a package through its search GUI and command line interface. All package information are stored in a centralised repository which Nuget tools (GUI and PowerShell based) uses to download and configure the package into our projects. The component (or package) developer will create a Nuget package and register it with Nuget centralised repository for developers from all over the world to consume through Nuget tool.

Nuget package manager is now part of Visual Studio installations as Visual Studio extension. Until Visual Studio 2015, the Nuget package information are maintained in a XML based file called packages.config and the package binaries are downloaded into a folder called Packages (under project folder where you find the solution file) for all project types. In Visual Studio 2015, for Asp.Net Core projects, these were moved into a new file called project.json file. With the release of Visual Studio 2017, the project.json is also retired and the Nuget package configurations are now maintained as part of the Visual Studio project file itself (.csproj) as project dependencies. The Nuget package that our project uses are commonly referred as dependencies.

For Asp.Net Core projects (the newer version of Asp.Net), Nuget package manager plays a very important role. Asp.Net Core framework is completely open source and modular in nature. All framework components including .Net runtime are packaged and available as Nuget packages. This means, for any Asp.Net Core projects all the projects dependent packages and runtime components are included in the project by the Nuget package manager.

To add a new Nuget package into a project, right click project in solution explorer and click “Manage Nuget Packages..”

This will bring Nuget GUI like below,

The Browse tab helps you to search an available package and install it. For example, type “Entity Framework” in Search textbox and enter. This will load the Entity Framework Nuget package in results section. Click “Install” to install the package into the project. It will ask user consent for End User Agreement during installing, click “Agree”.

The Installed tab lists all the packages we have included in our project.

The Updates tab list only packages that has a latest update available.