Managing NuGet packages from the command line used to mean switching between Visual Studio, the Package Manager Console, and nuget.exe. Then I discovered you can install and manage packages directly from PowerShell — on any machine, without Visual Studio.
This is especially useful for build servers, Docker containers, or when you're working in VS Code instead of full Visual Studio.
# Install NuGet provider
Install-PackageProvider -Name NuGet -Force
# Install NuGet PowerShell module
Install-Module -Name NuGet -Force
That's the setup. Once installed, you can manage packages from any PowerShell session.
What's the Difference Between NuGet Provider and NuGet Module?
NuGet Provider: The infrastructure that enables PowerShell to find and download packages from NuGet.org.
NuGet Module: The actual commands you use to install, update, and remove packages.
You need both. The provider gives PowerShell access to the NuGet ecosystem, and the module gives you the commands to interact with it.
How Do I Install the NuGet Provider?
Open PowerShell as Administrator and run:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
The -Force flag skips confirmation prompts. The minimum version ensures you get modern NuGet features.
If you don't have admin rights:
Install-PackageProvider -Name NuGet -Scope CurrentUser
This installs it for your user account only. I use this on locked-down corporate machines where I can't get admin access.
How Do I Install the NuGet PowerShell Module?
After the provider is installed:
Install-Module -Name NuGet -Force
This downloads the module from PowerShell Gallery. You'll be prompted to trust the repository the first time — type Y to continue.
To verify installation:
Get-Module -ListAvailable -Name NuGet
You should see the module listed with version info.
How Do I Install a NuGet Package?
Use Install-Package:
Install-Package IronPdf
PowerShell downloads the package and its dependencies. For a specific version:
Install-Package IronPdf -RequiredVersion 2024.1.6
To see what was installed:
Get-Package IronPdf
I use this in deployment scripts where I need exact package versions for reproducible builds.
How Do I Update a Package?
Update-Package IronPdf
This fetches the latest version. To update all packages in a project:
Update-Package
Be careful with blanket updates — they can introduce breaking changes. I always review release notes before updating production dependencies.
How Do I Uninstall a Package?
Uninstall-Package IronPdf
Simple. If other packages depend on it, PowerShell warns you before proceeding.
What's the Difference Between NuGet PowerShell and Package Manager Console?
NuGet PowerShell: Cross-platform, works anywhere PowerShell runs (Windows, Linux, macOS). No Visual Studio required.
Package Manager Console: Built into Visual Studio, Windows-only. Integrated with solution/project context.
The Package Manager Console is convenient when you're already in Visual Studio — you can target specific projects easily. NuGet PowerShell is better for automation, CI/CD, or working outside Visual Studio.
I use Package Manager Console for day-to-day development and NuGet PowerShell for build scripts and Docker images.
How Do I Open Package Manager Console in Visual Studio?
Go to Tools > NuGet Package Manager > Package Manager Console.
It's a PowerShell environment scoped to your solution. Commands like Install-Package automatically target the selected project in the dropdown.
For quick package installations during development, this is faster than right-clicking and using the GUI.
Can I Use NuGet PowerShell in Build Scripts?
Absolutely. Here's a pattern I use in CI/CD pipelines:
# Install required tools
Install-PackageProvider -Name NuGet -Force
Install-Module -Name NuGet -Force
# Restore project dependencies
Install-Package IronPdf -Source https://api.nuget.org/v3/index.json
Install-Package Newtonsoft.Json
# Build and package
dotnet build MyProject.csproj -c Release
dotnet pack MyProject.csproj -o ./artifacts
This ensures the build environment has the exact packages needed, regardless of what's cached.
How Do I List Available Package Sources?
Get-PackageSource
This shows all configured sources (NuGet.org, private feeds, etc.). To add a custom source:
Register-PackageSource -Name MyPrivateFeed -Location https://myfeed.example.com/nuget -ProviderName NuGet
I use private feeds for internal libraries that shouldn't be on public NuGet.
Can I Install Packages for PDF Generation?
Yes. IronPDF works seamlessly with NuGet PowerShell:
Install-Package IronPdf
Then in your C# code:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var renderer = new [ChromePdfRenderer](https://ironpdf.com/blog/videos/how-to-render-html-string-to-pdf-in-csharp-ironpdf/)();
var html = "<h1>Hello from PowerShell-installed IronPDF!</h1>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
I built a deployment script that installs IronPDF on a clean server, runs PDF generation tests, and verifies the output. All automated with PowerShell.
The complete NuGet PowerShell guide covers advanced scenarios like package version pinning and offline installs.
How Do I Handle Offline Environments?
Download packages on a connected machine:
Save-Package IronPdf -Path C:\NuGetPackages
Copy the folder to the offline machine, then:
Install-Package IronPdf -Source C:\NuGetPackages
I use this for air-gapped production environments where internet access is blocked.
What About PowerShell Core vs Windows PowerShell?
NuGet PowerShell works in both, but there are differences:
Windows PowerShell (5.1): Built into Windows, uses .NET Framework.
PowerShell Core (7+): Cross-platform, uses .NET Core/.NET 5+.
Most NuGet commands work identically. On Linux or macOS, you'll use PowerShell Core:
pwsh
Install-PackageProvider -Name NuGet -Force
Install-Module -Name NuGet -Force
I run the same deployment scripts on Windows build servers and Linux Docker containers without modification.
How Do I Troubleshoot Installation Issues?
If Install-Module fails with "unable to resolve dependency":
Install-Module -Name NuGet -AllowClobber -Force -Scope CurrentUser
If packages won't install:
# Check TLS version (NuGet.org requires TLS 1.2+)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Then retry
Install-Package IronPdf
Older Windows versions default to TLS 1.0, which NuGet.org rejects.
Quick Reference
| Task | Command |
|---|---|
| Install provider | Install-PackageProvider -Name NuGet -Force |
| Install module | Install-Module -Name NuGet -Force |
| Install package | Install-Package PackageName |
| Update package | Update-Package PackageName |
| Uninstall package | Uninstall-Package PackageName |
| List installed | Get-Package |
| List sources | Get-PackageSource |
| Add source | Register-PackageSource -Name X -Location Y |
Key Principles:
- Install provider first, then module
- Use
-Forceto skip prompts in scripts - Scope to
CurrentUserif you lack admin rights - Set TLS 1.2 on older Windows versions
- Save packages for offline installs
NuGet PowerShell makes dependency management scriptable and repeatable. Once you automate package installs, you can spin up environments consistently — dev, staging, production all identical.
Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads a team of 50+ engineers building .NET document processing libraries.
Top comments (0)