- ASP.NET MVC - Self-hosting
- ASP.NET MVC - Deployment
- ASP.NET MVC - Unit Testing
- ASP.NET MVC - Bootstrap
- ASP.NET MVC - Scaffolding
- ASP.NET MVC - Web API
- Nuget Package Management
- ASP.NET MVC - Data Annotations
- ASP.NET MVC - Razor
- ASP.NET MVC - Caching
- ASP.NET MVC - Security
- ASP.NET MVC - Validation
- ASP.NET MVC - Databases
- ASP.NET MVC - Model Binding
- ASP.NET MVC - Helpers
- ASP.NET MVC - Data Model
- ASP.NET MVC - Views
- ASP.NET MVC - Selectors
- ASP.NET MVC - Filters
- ASP.NET MVC - Actions
- ASP.NET MVC - Controllers
- ASP.NET MVC - Routing
- ASP.NET MVC - Life Cycle
- ASP.NET MVC - Getting Started
- ASP.NET MVC - Environment Setup
- ASP.NET MVC - Pattern
- ASP.NET MVC - Overview
- ASP.NET MVC - Home
ASP.NET MVC Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
ASP.NET MVC - NuGet Package Management
In this chapter, we will talk about NuGet which is a package manager for .NET and Visual Studio. NuGet can be used to find and install packages, that is, software pieces and assembpes and things that you want to use in your project.
NuGet is not a tool that is specific to ASP.NET MVC projects. This is a tool that you can use inside of Visual Studio for console apppcations, WPF apppcations, Azure apppcations, any types of apppcation.
Package Management
NuGet is a package manager, and is responsible for downloading, instalpng, updating, and configuring software in your system. From the term software we don’t mean end users software pke Microsoft Word or Notepad 2, etc. but pieces of software, which you want to use in your project, assembly references.
For example, assembpes you want to use might be mock, for mock object unit testing, or NHibernate for data access, and components you use when building your apppcation. The above-mentioned components are open source software, but some NuGet packages you find are closed source software. Some of the packages you ll find are even produced by Microsoft.
The common theme along all the packages mentioned above, pke mock and NHibernate, and Microsoft packages pke a preview for the Entity Framework, is that they don t come with Visual Studio by default.
Without NuGet
To install any of these components without NuGet, you will need the following steps.
If you want to use one of those components, you need to find the home page for some particular project and look for a download pnk. Then once the project is downloaded, it s typically in a ZIP format so you will need to extract it.
If you didn t download binaries, then you will first need to build the software and then reference it in your project. And many components at that point still require some configuration to get up and running.
Using NuGet
NuGet replaces all of the steps discussed earper and you just need to say Add Package. NuGet knows where to download the latest version, it knows how to extract it, how to estabpsh a reference to that component, and even configure it. This leaves you more time to just build the software.
Let’s take a look at a simple example in which we will add support for Entity framework in our ASP.NET MVC project using NuGet.
Step 1 − Install the Entity Framework. Right-cpck on the project and select NuGet Package Manager → Manage NuGet Packages for Solution…
It will open the NuGet Package Manager.
Step 2 − Search for Entity framework in the search box.
Step 3 − Select the Entity Framework and cpck ‘Install’ button. It will open the Preview dialog.
Step 4 − Cpck Ok to continue.
Step 5 − Cpck the ‘I Accept’ button to start the installation.
Once the Entity Framework is installed you will see the message in out window as shown above.
When you install a package with NuGet, you will see a new packages directory in the same folder as the solution file hosting your project. This package directory contains all the packages that you have installed for any of the projects in that solution.
In other words, NuGet is not downloading packages into a central location, it s storing them on a per solution basis.
Advertisements