What is NuGet? How to Use NuGet Packages?

What is NuGet?

NuGet is the package manager for .NET. NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.

NuGet is an essential tool for any modern development platform is a mechanism through which developers can create, share, and consume useful code. Often such code is bundled into “packages” that contain compiled code along with other content needed in the projects that consume these packages. NuGet package contains a single ZIP file with the extension of .nupkg that consists of compiled code (DLLs), and information like the package’s version number. 

Using NuGet from the Command Line

Visual Studio also provides the command-line interface to manage NuGet packages. It provides Power Shell-based console named “Package Manager Console”.

To open the console Go to Tools -> Library Package Manager -> Package Manager Console.

Installing a Package

To install a new package, use the following command:

Install-Package <PackageName>

For example:

Install-Package xyz

This command will install the xyz package in your current project.

Updating a Package

To update the NuGet package, use:

Update-Package <PackageName>

This command will update to the latest version of package. If you want to update a certain package, then use -version switch like below:

Update-Package xyz -version 1.1

To update all NuGet packages in your project, you can simply execute Update-Package command without any parameter.

Uninstalling a Package

To Uninstall the NuGet package, use:

Uninstall-Package <PackageName>

For example:

Uninstall-Package xyz

Post a Comment

If you have any questions or concerns, please let me know.

Previous Post Next Post