How to install the Nuget Package using PowerShell?


Nuget is the package management tool for the .NET and it is similar to PowerShellGet, MSI packages which support several commands and packages to work with PowerShell.

NuGet supports Install−Package, Update−Package, Find-Package, and Get−Package command and if Nuget package is not installed in your system, you may not find a package or install any package.

For more reference about Nuget, check the websites below.

https://www.nuget.org

https://docs.microsoft.com/en-us/nuget/reference/powershell−reference

To install NuGet, we need to use the Install−PackageProvider command. Use the below command to install the Nuget package.

Install−PackageProvider −Name Nuget −Force

On some machines, you will get the error message regarding downloading the package from the internet. If you have the proxy set in your environment, you can configure the proxy, or if there is no issue with proxy, and if your System TLS version is 1.1 then it should be first changed to 1.2 using the below command.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Once the above command runs successfully, use the first command to install the Nuget package.

When the NuGet package is installed, use the below command to check if the Nuget provider exists on the system or not.

Get−PackageProvider

You will get the output as below and find the NUGET package there.

Updated on: 25-Jan-2021

17K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements