푸터 콘텐츠로 바로가기
.NET 도움말
NuGet이란 무엇인가요(개발자를 위한 작동 방식 튜토리얼)

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.

What is NuGet? 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 lists 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 Features

  • 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 APIs of the packages are accessible to the rest of the project code.

What is NuGet, Figure 1

NuGet Tools

There are six tools which are used to manage NuGet Packages.

.NET CLI

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.

NuGet.exe CLI

It is a CLI for .NET Framework libraries and non-SDK-style projects aiming at .NET Standard libraries. It provides all the capabilities 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 use 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 projects in Visual Studio. This tool is available only for Mac users.

MSBuild

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 Tools from the Top Menu Bar and select NuGet Package Manager > Manage NuGet package for Solutions.

A new window will appear as shown below.

What is NuGet, Figure 2

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.

What is NuGet, Figure 3

Click on the Install Button, the library will be installed and made ready for use.

IronBarcode NuGet Package Details 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 them 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.

What is NuGet, Figure 4

Let's install a package using the Package Manager Console.

The Install-Package 'package-Name' command is used to install the package. For example, to install the IronOCR package:

Install-Package IronPdf

Explore IronOCR NuGet Package 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.

Read more technical documentation about IronOCR from the product website.

Some Useful NuGet Packages

This section will describe some useful NuGet Packages available for working with databases and files.

Entity Framework

Discover Entity Framework NuGet Package 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 Guide for Entity Framework provides more information about Entity Framework's capabilities.

IronPDF

IronPDF NuGet Package solves the difficult problem of adding PDF processing capabilities to apps. IronPDF automates the conversion of formatted documents to PDF and also allows developers 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 APIs on .NET Framework, and .NET Core.

Read more about IronPDF on its product documentation page.

IronXL

IronXL NuGet Package 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 the comprehensive product documentation.

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 when purchasing the complete suite. All purchases include lifetime product support.

Summary

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.

자주 묻는 질문

C#에서 HTML을 PDF로 변환하려면 어떻게 해야 하나요?

IronPDF의 RenderHtmlAsPdf 메서드를 사용하여 HTML 문자열을 PDF로 변환할 수 있습니다. 또한 RenderHtmlFileAsPdf 메서드를 사용하여 HTML 파일을 PDF로 변환할 수도 있습니다.

NuGet이란 무엇이며 .NET 개발자에게 중요한 이유는 무엇인가요?

NuGet은 .NET 개발자가 패키지 코드를 효율적으로 생성, 공유 및 활용할 수 있도록 해주는 패키지 관리 시스템입니다. 타사 라이브러리 및 종속성 관리를 간소화하여 올바른 버전을 사용하고 패키지를 쉽게 업데이트 및 복원할 수 있도록 합니다.

.NET CLI를 사용하여 NuGet 패키지를 설치하려면 어떻게 해야 하나요?

.NET CLI를 사용하여 NuGet 패키지를 설치하려면 dotnet add package [PackageName] 명령을 사용하면 됩니다. 이 명령은 지정된 패키지를 프로젝트에 추가하여 패키지 관리 프로세스를 간소화합니다.

Visual Studio에서 NuGet 패키지를 관리하는 데 필수적인 도구는 무엇인가요?

Visual Studio에서 NuGet 패키지를 관리하기 위한 필수 도구로는 패키지 관리자 UI, 패키지 관리자 콘솔 및 .NET CLI가 있습니다. 이러한 도구를 사용하면 프로젝트 내에서 패키지를 효율적으로 검색, 설치 및 업데이트할 수 있습니다.

NuGet 패키지에 비공개 호스팅을 사용하면 어떤 이점이 있나요?

NuGet 패키지를 위한 비공개 호스팅을 통해 개발자는 특정 그룹이나 조직 내에서 패키지를 안전하게 공유할 수 있습니다. 이렇게 하면 권한이 부여된 사용자만 특정 패키지에 액세스할 수 있으므로 코드 배포에 대한 보안 및 제어가 강화됩니다.

NuGet 패키지 관리자 콘솔은 어떻게 패키지 관리를 용이하게 하나요?

개발자는 개발 환경 내에서 직접 패키지를 설치, 업데이트 및 관리하기 위한 명령을 실행할 수 있는 Visual Studio의 NuGet 패키지 관리자 콘솔을 사용할 수 있습니다. 이는 패키지 종속성 및 버전을 효율적으로 처리할 수 있는 강력한 인터페이스를 제공합니다.

NuGet 패키지에서 매니페스트는 어떤 역할을 하나요?

NuGet 패키지의 매니페스트에는 패키지의 버전 번호 및 기타 중요한 정보와 같은 메타데이터가 포함되어 있습니다. 이 메타데이터는 프로젝트 내에서 종속성을 식별, 관리 및 해결하는 데 매우 중요합니다.

NuGet은 .NET이 아닌 프로젝트에도 사용할 수 있나요?

NuGet은 주로 .NET 프로젝트를 위해 설계되었지만, 그 인프라는 다양한 다른 프로젝트의 패키지 관리를 지원할 수 있습니다. 하지만 그 잠재력과 기능을 최대한 활용하려면 .NET 에코시스템 내에서 사용하는 것이 가장 좋습니다.

NuGet의 캐싱 메커니즘은 패키지 관리를 어떻게 간소화하나요?

NuGet의 캐싱 메커니즘을 사용하면 패키지 데이터를 로컬에 저장하여 패키지를 쉽게 설치하고 다시 설치할 수 있습니다. 따라서 중앙 리포지토리에서 패키지를 반복적으로 다운로드할 필요가 줄어들어 개발 프로세스의 속도가 빨라집니다.

인기 있는 NuGet 패키지의 예로는 어떤 것이 있나요?

인기 있는 NuGet 패키지에는 데이터베이스 상호 작용을 위한 엔티티 프레임워크, PDF 처리를 위한 IronPDF, 스프레드시트 조작을 위한 IronXL 등이 있습니다. 이러한 패키지는 개발자에게 .NET 애플리케이션을 향상시킬 수 있는 강력한 도구를 제공합니다.

커티스 차우
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.