Website Design Chester by the Informatics Centre

NuGet Package Manager

NuGet is a package manager which comes bundled with Visual Studio. It allows developers to quickly and easily install new functionality into their applications just by executing a few simple commands and letting NuGet do the rest of the work.

Packages can drop new files into a project and import their settings into configuration files automatically when they are installed so that they are ready to use straight away. This can be a powerful tool for speeding up development since it is no longer necessary to hunt down the appropriate library and its documentation to get it working.

How do I use it?

You can get started with NuGet Package Manager by opening its tab at the bottom of Visual Studio (if it's not there you can go to View -> Other Windows -> Package Manager Console to open it).

Let's say we wanted to set up Entity Framework in our web application. If we open the package manager and enter the command"install-Package EntityFramework" it will automatically be downloaded and configured ready to use.

If we later want to uninstall Entity Framework we can do that by executing the "Uninstall-Package EntityFramework" command which will remove its assembly and any entries it has made into the web.config file.

What can I install?

There are a wide variety of packages available to install through NuGet. Our favourites include:-

  • Entity Framework
  • jQuery
  • jQuery UI Combined
  • Json.NET
  • AutoFac
  • You can find other packages which are available at http://www.nuget.org/packages

    Command List

    Command Result
    Install-Package {PackageName} Installs the package specified
    Uninstall-Package {PackageName} Uninstalls the package specified
    Update-Package {PackageName} Updates the package specified to the latest version available
    Get-Package Lists the packages currently installed in the project

    The Package Manager Console also supports to use of the tab key to autocomplete words. For example, we can type "Install" and press tab it will complete the command to "Install-Package". You can then continue typing "Entity" and press tab to be provided suggestions of the packages available to install.

    You can find out more about NuGet and how to use it at their website http://www.nuget.org/.

    View all Informatics Centre blog posts.