Tech Talk A software developer on all things tech, and then some


Common NuGet Package Manager Console Commands You Should Know

Within Visual Studio there is a console window that many know little about. I myself have finally started researching ways to improve my productivity via this console window, the Package Manager Console. In doing my research and using some of these commands on a daily or weekly basis, I figured I'd jot these down for my own notes, and anybody that uses NuGet.

Update Package

The update package without a project name will iteratively progress through your solution, find the package by the specified name, then re-install that package of the same version. This is my favorite command to run when pulling up a project from a freshly created branch.

Update-Package –reinstall [PackageName]

When you include a project name, the console will install the packages just within that project. Useful when you have one project causing an issue and you don't want to run the reinstall command of the entire solution.

Update-Package –reinstall -project [ProjectName]

Install Package

If you know the package name already you want to include in your project, the following command will be a quick alternative to the GUI of the NuGet Package Manager.

Install-Package [PackageName] [ProjectName]

Get Package

If you want to view the available packages via a supplied filter (There are thousands of packages), the following command will do just that!

Get-Package -ListAvailable -Filter [PackageName]


Additional Reference:

Want to learn some more Powershell / NuGet commands to speed up the NuGet experience? Take a look at the documentation on NuGet's site.



How to Install and Run PowerShell

The install PowerShell on a version of Windows before Windows 7 (Windows Server 2k3, 2k8, Vista, or XP), visit the Windows Management Framework download page. This download includes Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0. For those interested, you can also download just WinRM and PowerShell at that link as well.

Note : If you are using Windows 7, PowerShell is already installed.

Running and Configuring PowerShell

PowerShell out of the box does not allow scripts to be ran. You will need to run PowerShell and set the Execution Policy.

  • Start PowerShell
  • Type Set-ExecutionPolicy (Do not hit enter yet)
  • Enter one of the following after the Set-ExecutionPolicy
    • Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode.
    • AllSigned - Only scripts signed by a trusted publisher can be run.
    • RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run.
    • Unrestricted - No restrictions; all Windows PowerShell scripts can be run.

For Example, on my development machine in which I wanted full control, I typed

Set-ExecutionPolicy Unrestricted

This should get you up and going. There will be a part 2 soon with simple scripts to get you started scripting. Stay tuned and happy scripting!

%d bloggers like this: