Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Install Nuget Package in C#?

Improve Article
Save Article
Like Article
  • Last Updated : 15 Dec, 2022
Improve Article
Save Article
Like Article

In this tutorial, we will be seeing how to install NuGet packages in C#. NuGet is the official package-manager for .NET. Packages are basically compiled libraries with some descriptive metadata. NuGet is an important tool for any modern development platform through which developers can create, share, and consume useful code. NuGet packages can also be defined as “re-usable and pre-defined pieces of code which benefit other developers as well”.

Prerequisites: Visual Studio, Stable Internet, C#

Downloading and Installation of Nuget package in C#

Follow the further steps to install Nuget Package in C#

Step 1: Creating or Opening an existing project

NuGet packets are installed in projects and hence we first need to create a project or open an existing one.

In this particular tutorial, we will be creating a MVC project. Here we are using Visual Studio 2019 and naming the project as NugetDemo.

Click on create a new project and choose ASP.NET Web Application(.NET Framework) and click next.

ASP.NET Web Application


Step 2: Then we name the project. Here it is named as NugetDemo and click Create.

Nuget Demo


Step 3: Next click MVC and click on the create button.

ASP.NET MVC applications


After following the above steps, the project has been created and we shall now see the NuGet Package Installation. We are going to be installing the Bootstrap package. For more details on Bootstrap click here.

There are multiple approaches to do so.

Approach 1: Using Packet manager console to install Bootstrap package

Step 4: Go to Tools->NuGet Package Manager->Packet Manager Console

Packet Manager Console


Step 5: Installing via commands

The general command syntax:  Install-Package <package_name>

For Bootstrap the command will be:  Install-Package bootstrap

Once installed you will get the following screen.

Install bootstrap package


Note: You can even specify the version name however by default it is the latest one like in case of bootstrap it is 5.2.2. 

For Bootstrap the command with the version specified will be: Install-Package bootstrap -Version 5.2.2

Once installed, you will get the following acknowledgment.

Install-Package bootstrap -Version 5.2.2


Approach 2: Using Manage packages for solution to install Bootstrap package

Step 4: Go to Tools->NuGet Package Manager->Manage NuGet Packages for Solution… 

The below screen will appear and now search for the required package in Browse, and choose the version(optional).

Manage NuGet Packages for Solution


Step 5: Click install on the bottom right corner.

After clicking install wait for a few seconds and you shall get a confirmation as follows:

Nuget installed


Note: In order to install or uninstall NuGet packages make sure your project is not running. If it is, stop running, install or uninstall and then build the project and run.

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!