Home » PowerShell » How to Install NuGet Package using PowerShell

How to Install NuGet Package using PowerShell

To install the NuGet package in PowerShell, use the `Install-PackageProvider` command. NuGet is a package manager for .NET which supports a variety of commands and packages to work with PowerShell.

Using the NuGet package in PowerShell, developers can easily find and install packages from repositories.

In this article, we will discuss how to install the NuGet package using the PowerShell Install-PackageProvider command.

How to Install NuGet Package in PowerShell

To install the NuGet package in PowerShell, use the Install-PackageProvider command. It downloads and installs a package provider.

To do the installation of the NuGet package provider, follow the below steps:

  1. Open PowerShell Terminal – Launch the PowerShell terminal with Administrator privileges.
  2. Type the command – Install-PackageProvider -Name Nuget -Force
  3. Hit Enter
Install-PackageProvider -Name Nuget -Force  

In the above PowerShell script, the Install-PackageProvider command uses the Name parameter to specify the package provider name “NuGet“.

The output of the above PowerShell script downloads and installs the latest version of the NuGet Package provider.

Install NuGet Package Provider
Install NuGet Package Provider

When the Nuget package is successfully installed, use the Get-PackageProvider command in PowerShell to check if the NuGet package provider exists on the local system.

Get-PackageProvider -Name "Nuget" 

The output of the above PowerShell script returns the package provider if it exists on the local computer.

PS C:\> Get-PackageProvider -Name "Nuget"                 
                                                                                        
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleas...

Conclusion

I hope the above article on how to install the NuGet package using the PowerShell Install-PackageProvider command is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

PackageManagement

Get-Package

Find-Package

Install-Package

Get-PackageProvider

Get-PackageSource

Register-PackageSource