Updated October 31, 2022
What is NuGet?
A system that allows developers to write, exchange, and use functional code is a crucial component of any modern development platform. This functional code is bundled in "packages" that also include other materials required by the projects that use them, such as compiled code (in the form of DLLs).
The Microsoft-supported method of code sharing for .NET (including .NET Core) is NuGet. NuGet enables the production, hosting, and retrieval of packages for .NET Frameworks. Software packages that NuGet manages are called NuGet packages.
A NuGet package is just a zip file with the extension .nupkg. it contains all the DLLs required to make the software function. It also contains a descriptive manifest that the package's version number, among other things. Developers just need to install the NuGet package, and they can use the methods provided by that package.
- NuGet adds private hosting support to the central nuget.org repository.
- NuGet provides the tools that developers need to create, publish, and install packages.
- NuGet keeps track of the packages used in a project and allows you to restore and update those packages from that list.
- NuGet keeps track of all the specifications pertaining to how packages are structured, such as localization and how they are referenced.
- NuGet provides numerous APIs for programmatically interacting with all of its services, as well as support for developers who publish Visual Studio extensions.
- NuGet includes a package cache and a global folder for packages to make installation and reinstallation easier. If a package is already present on the local machine, the cache will not download it from the central repository, and will instead serve the package from the cache.
How NuGet Package works?
NuGet, as a public host, maintains a central repository of over 100,000 unique packages. Every day, millions of .NET/.NET Core developers use these packages. NuGet also lets you host packages privately in the cloud (for example, on Azure DevOps), on a private network, or even on your local file system. As a result, those packages are only available to developers who have access to the host, allowing you to make packages available to a specific group of consumers.
A host, whatever its nature, serves as the link between package creators and package consumers. Creators develop useful NuGet packages and distribute them to a host. Consumers then search accessible hosts for useful and compatible packages, downloading and including those packages in their projects. Once installed in a project, the API's of the packages are accessible to the rest of the project code.
There are six tools which are used to manage NuGet Packages.
It is a command line Interface (CLI) for .NET Core and .NET Standard libraries, as well as for SDK-style projects targeting the .NET Framework (see SDK attribute). Certain NuGet CLI capabilities are available directly within the .NET Core tool chain. The .NET CLI, like the nuget.exe CLI, does not interact with Visual Studio projects.
It is a CLI for .NET Framework libraries and non-SDK-style projects aiming at .NET Standard libraries. It provides all the capabilities of of the .NET CLI, with some commands only applicable to package creators and other commands only to consumers. Package creators, for example, use the NuGet
pack command to generate a package from various assemblies and related files. Package users use
NuGet install to include packages in a project folder. Both package developers and package users uses
NuGet config to set NuGet configuration variables.
The NuGet CLI does not interact with Visual Studio projects because it is a platform-agnostic tool.
Package Manager Console
The Package Manager Console provides PowerShell commands for installing and managing packages within Visual Studio projects.
Package Manager UI
The Package Manager UI provides a user-friendly interface for installing and managing packages for projects within Visual Studio.
Manage NuGet Package Manager UI
This tool also provides a user-friendly interface for installing and managing packages in for projects in Visual Studio. This tool is available only for Mac users.
MSBuild allows users to create and restore packages used in a project directly from the MSBuild tool chain.
Package Manager UI and Package Manager Console are most widely used tools for managing NuGet packages. We will now explore how they are used.
Use of the NuGet Package Manager UI
In Visual Studio, click on on Tools from the Top Menu Bar and select NuGet Package Manager > Manage NuGet package for Solutions.
A new window will appear as shown below.
In the Installed tab, all the NuGet packages that are already installed will appear here.
Click on the Browse Button and write the name of a package in the Search Bar. We will search for IronBarcode as an example.
Click on the Install Button, the library will be installed and made ready for use.
IronBarcode is a library developed and maintained by Iron Software that helps C# Software Engineers read and write Barcodes and QR Codes in .NET applications.
Core features include:
- Read single or multiple Barcodes and QR Codes from images or PDFs.
- Image correction for skewing, orientation, noise, low resolution, contrast, etc.
- Create barcodes and apply to images or PDF documents.
- Embed barcodes into HTML documents.
- Style Barcodes and add annotation text.
- QR Code Writing allows adding of logos, colors, and advanced QR alignment.
Learn more about IronBarcode from the product documentation page.
Use of the Package Manager Console
In Visual Studio, click on Tools from the Top Menu Bar and select NuGet Package Manager => Package Manager console.
The Package Manager Console window will appear as shown below.
Let's install a package using the Package Manager Console.
Install-Package 'package-Name' command is used to install the package. For Instance:
IronOCR is a C# software library that allows .NET software developers to detect and read text from images and PDF documents. It uses the most advanced Tesseract engine known anywhere. IronOCR shines above all other OCR libraries when working with real world images riddled with imperfections (i.e. digital noise, low-quality resolutions, etc.) It supports multiple programming languages.
Some Useful NuGet Packages
This section will describe some useful NuGet Packages available for working with databases and files.
Entity Framework is the most common and powerful NuGet Package available for working with databases in .NET applications.
It is a Microsoft-supported open-source ORM framework that allows developers to work with data using domain-specific objects rather than using the underlying database tables and columns where the data is stored. When working with data, developers can work at a higher level of abstraction. This allows them to create and maintain data-oriented applications with less code than traditional applications.
There are separate NuGet packages available for managing SQL server, Oracle, MySQL, and PostgreSQL database servers.
The Getting-Started page provides more information about Entity Framework's capabilities.
IronPDF solves the difficult problem of adding PDF processing capabilities to apps. IronPDF automates the conversion of formatted documents to PDF, and also allows develoeprs to to create, edit, and export PDF documents.
The main features of IronPDF include:
- Convert web forms, local HTML pages, and other web pages to PDF with .NET.
- Allow users to download documents, send them by email, or store them in the cloud.
- Produce invoices, quotes, reports, contracts, and other documents.
- Work with ASP .NET, ASP .NET Core, web forms, MVC, Web API's on .NET Framework, and .NET Core.
Read more about IronPDF on its product documentation page.
IronXL helps C# Software Engineers read, create, and edit spreadsheet files in .NET applications. IronXL works well without the use of Office Excel Interop, and does not require additional dependencies or the need to install Microsoft Office.
You can learn more about IronXL from here.
Iron Software provides all five libraries (IronPDF, IronXL, IronBarcode, IronWebscraper, and IronOCR) in a single .NET Suite. You can get all five libraries for the price of two on purchasing the complete suite. All purchases include lifetime product support.
NuGet is the package manager for .NET applications. The NuGet client tools provide the ability to create, share, and retrieve packages. The NuGet Gallery is the central package repository used by all package authors and consumers.
- NuGet provides the central nuget.org repository with support for private hosting.
- NuGet provides the tools developers need for creating, publishing, and installing packages.
- NuGet maintains a reference of packages used in a project and the ability to restore and update those packages from that list.