Installing NuGet Packages In Visual Studio

Introduction
 
We can say that NuGet packages are predefined pieces of code that are reusable for other developers. You can add them in your project and use that Nuget functionality where ever you want. We can also say that it's like a platform where developers can create and share code to the world. It contains DLL compile code, which is nearly impossible to decrypt. 
 
Prerequisites
  • Visual Studio
Step 1 - Create a Project
  • We can install NuGet packages in any .NET project that supports the same target framework as that of the created project.
  • For this demo, I'm using a normal MVC Project.

    Install NuGet packages in Visual Studio

    Install NuGet packages in Visual Studio
Step 2 - Open NuGet Package Manager

Now, there are two options to open the NuGet Package Manager window.
  1. Select Tools > NugGet Package Manager > Manage NuGet Packages for solution.

    Install NuGet packages in Visual Studio

  2. Go to your Solution Explorer, right-click on References, and choose Manage NuGet Packages.

    Install NuGet packages in Visual Studio 
Step 3 - Search and install your required NuGet.

Install NuGet packages in Visual Studio 
  • In this window, you can search, install, uninstall, and update any NuGet Package and also see the full list of installed NuGet Packages.
  • Once you click on the Install button and click on "I Agree" from the pop-up window, then that particular package will install/add to your project.
  • Here, I am installing EntityFramwork NuGet Package.
Once you have installed it successfully, the following message will be displayed.

Install NuGet packages in Visual Studio
 
Here, you can see your installed project. Go to Solution Explorer > Reference, and expand it.

Install NuGet packages in Visual Studio 
 
Now, you can access that package/code into your project.
 
Note

You can also install NuGet using the Package Manager Console.

Step 1 - Select Tools > NuGet Package Manager > Package Manager Console.

Install NuGet packages in Visual Studio 
 
It will open a console in the bottom of the window. 
 
Step 2 - Select your project and execute the command to install the package.

Install NuGet packages in Visual Studio 
 
If it's a valid command, then the package will be installed to your project.


Similar Articles