Skip to footer content
.NET HELP

Install NuGet Powershell (How it Works for Developers Tutorial)

NuGet is a package manager for .NET that simplifies adding third-party libraries, frameworks, and tools to a project. With NuGet, developers can quickly find and install packages from a central repository, manage dependencies, and update packages to their latest versions. NuGet PowerShell is a powerful tool for managing packages and dependencies in .NET projects. With NuGet PowerShell, developers can quickly find and install packages from a central repository, manage dependencies, and update packages to their latest versions using PowerShell commands.

NuGet PowerShell is an extension of NuGet that provides a PowerShell interface for managing packages. PowerShell is a powerful command-line interface that provides a scripting environment for Windows systems. It is built on top of the .NET Framework, making it an ideal choice for .NET developers who want to manage packages and dependencies using a command-line interface.

In this article, we will cover the basics of NuGet PowerShell and provide an overview of the different PowerShell commands available for managing packages and dependencies in .NET projects.

Installing NuGet PowerShell

Before we can use NuGet in PowerShell, we need to install the NuGet provider and module. NuGet PowerShell can be installed via the PowerShell Gallery, which is a public repository of PowerShell modules. Here are the steps to take:

  1. Open PowerShell as an administrator. To do this, right-click on the PowerShell icon and select "Run as administrator."

PDF API C# (Code Example Tutorial): Figure 1 - PowerShell in Admin

Install NuGet Provider

Install the NuGet package provider by running the following command:

Install-PackageProvider -Name NuGet -Force
Install-PackageProvider -Name NuGet -Force
SHELL

PDF API C# (Code Example Tutorial): Figure 2 - Install NuGet Provider

This command downloads and installs the latest version of the NuGet package provider, which is used to interact with the NuGet repository. NuGet Provider version 2.8.5.208 has been installed in our system. Restarting PowerShell is not required.

Install NuGet PowerShell Module

Once the package provider is installed, we need to install the NuGet PowerShell module by running the following command:

Install-Module -Name NuGet -Force
Install-Module -Name NuGet -Force
SHELL

PDF API C# (Code Example Tutorial): Figure 3 - Package Provider NuGet

This command downloads and installs the latest version of the NuGet PowerShell module, which provides PowerShell commands for interacting with the NuGet repository.

Verify that the module is installed by running the following command:

Get-Module -ListAvailable -Name NuGet
Get-Module -ListAvailable -Name NuGet
SHELL

PDF API C# (Code Example Tutorial): Figure 4

This command lists all installed modules that match the name "NuGet." If the module is installed correctly, you should see a list of modules that includes "NuGet."

Using NuGet PowerShell

Now that we have NuGet PowerShell installed, we can use it to manage packages and dependencies in our .NET projects. Here are some of the most commonly used PowerShell commands for working with NuGet packages:

Install-Package

The Install-Package cmdlet installs a software package and its dependencies.

Install-Package packageName

One example of a NuGet package that developers might find useful is the IronPDF package on NuGet. IronPDF is a .NET library developed by Iron Software that allows developers to create and manipulate PDF documents from their .NET applications. It provides an easy-to-use API for creating and editing PDF documents, including support for HTML-to-PDF conversion, page manipulation, and document security protocols. IronPDF is a popular choice for developers who want to add PDF generation and manipulation capabilities to their .NET applications. Using NuGet PowerShell, developers can quickly install the IronPDF software packages and start using them in their projects.

Install-Package IronPdf

This command will download and install the latest version of the IronPDF package and its dependencies.

Get-Package

The Get-Package command can be used to view the installed packages. This command displays a list of all the packages installed on the system, along with their version numbers and dependencies. For example, to view the installed version of the IronPDF package, run the following command:

Get-Package IronPDF
Get-Package IronPDF
SHELL

Uninstall-Package

The Uninstall-Package command can be used to uninstall packages from the system. For example, to uninstall the IronPDF package, run the following command:

Uninstall-Package IronPDF
Uninstall-Package IronPDF
SHELL

This command will remove the IronPDF package and its dependencies from the system.

Update-Package

NuGet PowerShell also provides the ability to update packages to their latest versions. The Update-Package command is used to update a package to the latest version. For example, to update the IronPDF package to its latest version, run the following command:

Update-Package IronPDF
Update-Package IronPDF
SHELL

This command will update the IronPDF package to its latest version along with its dependencies.

Get-PackageSource

This command lists all configured package sources. For example, to list all configured package sources, run the following command:

Get-PackageSource
Get-PackageSource
SHELL

NuGet Package Manager Console

The NuGet Package Manager Console is a command-line interface (CLI) tool that comes with the NuGet package manager for .NET framework applications. It is designed to provide developers with a powerful way to manage NuGet packages and their dependencies within Visual Studio.

The console allows developers to install, update, and remove NuGet packages from their projects using simple command-line syntax. It also enables users to manage their packages by creating and restoring package references, configuring package sources, and creating package specifications.

One of the significant benefits of using the NuGet Package Manager Console is that it can automate the process of installing and updating packages in a project. Developers can create scripts that automate the installation of packages or set up a build process that uses the console to install required packages before building the project.

Using NuGet Package Manager Console:

To open the Package Manager Console in Visual Studio, follow these steps:

  1. Open Visual Studio.
  2. Open the project or solution for which you want to manage NuGet packages.
  3. From the menu bar, click on Tools.
  4. In the dropdown menu, select NuGet Package Manager.
  5. From the submenu, select Package Manager Console.

PDF API C# (Code Example Tutorial): Figure 5

Using the Install-Package command:

The Install-Package command, just like NuGet PowerShell, is used to install packages from the NuGet repository. For example, to install the IronXL package on NuGet, run the following command:

Install-Package IronPdf

IronXL is a .NET library that provides a simple and easy-to-use API for reading, writing, and manipulating Excel files. The package supports all Excel file formats, including XLS, XLSX, and CSV, and provides features like cell formatting, formula calculation, data validation, and data filtering. With IronXL, developers can create powerful Excel-based applications quickly, without the need for Microsoft Office or any other third-party software. The package is available on NuGet, supported security protocols, and its documentation provides detailed examples and guides to help developers get started with using the library.

PDF API C# (Code Example Tutorial): Figure 6 - Package Management tool

NuGet PowerShell vs NuGet Package Manager Console

NuGet PowerShell is a command-line tool that allows developers to interact with NuGet packages using PowerShell commands. Unlike the NuGet Package Manager Console, which is a dedicated console tool for package management within Visual Studio, NuGet PowerShell can be used outside of Visual Studio and across different platforms. This makes it an ideal choice for developers who prefer to work outside of Visual Studio or use cross-platform development environments.

Additionally, NuGet PowerShell provides a more extensive range of features, including package creation, repository management, and version control, which gives developers greater flexibility and control over their packages. Overall, while both tools are useful for managing NuGet packages, NuGet PowerShell is a more versatile option that offers advanced features and cross-platform support.

NuGet PowerShell is also extensible, allowing developers to create custom packages and modules. Developers can use NuGet to create packages that include their own libraries and tools and then use NuGet PowerShell to install and manage those packages. This makes it easy for developers to share their code with others and reuse code across multiple projects.

Conclusion

NuGet PowerShell is an essential tool for any .NET developer who wants to manage package installation and dependencies. It provides a simple and powerful command-line interface for interacting with NuGet packages such as IronPDF and IronXL, making it easy to install and update packages. By leveraging NuGet PowerShell, developers can streamline their development processes, automate package management, and improve application stability.

Frequently Asked Questions

What is NuGet?

NuGet is a package manager for .NET that simplifies adding third-party libraries, frameworks, and tools to a project, allowing developers to manage dependencies and update packages to their latest versions.

What is NuGet PowerShell?

NuGet PowerShell is an extension of NuGet that provides a PowerShell interface for managing packages and dependencies in .NET projects, offering commands for package installation, update, and removal via a command-line interface.

How do I install the NuGet provider in PowerShell?

To install the NuGet provider in PowerShell, open PowerShell as an administrator and run the command: Install-PackageProvider -Name NuGet -Force.

How can I verify if the NuGet PowerShell module is installed?

You can verify the installation of the NuGet PowerShell module by running the command: Get-Module -ListAvailable -Name NuGet. This will list all installed modules that match the name 'NuGet'.

What is the purpose of the Install-Package cmdlet in NuGet PowerShell?

The Install-Package cmdlet is used to install a software package and its dependencies from the NuGet repository using PowerShell commands. For example, it can be used to install the IronPDF package, which allows developers to create and manipulate PDF documents from their .NET applications.

How do I update a package using NuGet PowerShell?

To update a package to the latest version using NuGet PowerShell, use the command: Update-Package packageName. This will update the specified package along with its dependencies. You can use this command to update packages like IronPDF to their latest versions.

What is the NuGet Package Manager Console?

The NuGet Package Manager Console is a command-line tool in Visual Studio that allows developers to manage NuGet packages and their dependencies within their projects. It supports installation, update, and removal of packages. Developers can use it to manage packages like IronXL for Excel file manipulation.

What are the differences between NuGet PowerShell and NuGet Package Manager Console?

NuGet PowerShell is a versatile command-line tool for managing packages outside of Visual Studio and across platforms, offering advanced features like package creation and repository management. In contrast, the NuGet Package Manager Console is integrated within Visual Studio for package management in projects. Both tools can manage packages like IronPDF and IronXL.

How can developers use NuGet PowerShell to manage custom packages?

Developers can use NuGet PowerShell to create custom packages with their own libraries and tools, which can then be installed and managed using NuGet PowerShell commands. This makes it easier to manage packages such as IronPDF and IronXL for specific project requirements.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.