Introduction
This article describes how to find, install, remove and update the NuGet Packages using the Commands Web API. For Commands we use the Package Manager Console. In the Web API we use a different package and need to install it in the application. Now we will explain the process of package installation.
- Finding the Package.
- Install The package.
- Remove The Package.
- Update The Package.
Find The Package:
For finding the package, first we need to open the Package Manager Console. We can open it as in the following:
- From the Tools menu.
- Select "Library Package Manager".
- Then select "Package Manager Console".
The Package Manager Console window looks like this:
Now you enter the Command in the Packager Manager Console window for finding all the packages available in the selected package source. We use the "Get-Package -ListAvailable" command.
Install the Package
For installing the package we need to know the package name and enter the command "Install-Package Packagename" in the Package Manager Console and press Enter. Here we install the Package "Elmah" so we type the command "Install-Package elmah " and press Enter. After installing this package it will be display as:
Now we check the "References" folder in the "Solution Explorer" in which it added the library of the "elmah" as libraries.
Now see the "Web.Config" file that applied some changes.The following image shows the changes:
Your application folder has a "packages" folder in which you can see the "elmah" package folder.
The "Packages" folder has a sub-folder of the installed package. This folder has all the files that are installed by the package.
Remove The Package
If you need to remove any package then that is possible. First you select the Package Manager Console. Go to "Tools", select "Library Package Manager", then select "Package Manager Console". If you do not know which package name you want to remove then just type the "Get-Package" command that will fetch all packages that are currently installed.
After finding the package that you want to remove then type the "Uninstall-Package elmah" command. This command will successfully remove the specified package.
Updating the Package
Go to the "Tools" menu, then select "Library Package Manager" and then select "Package Manager Console". For finding the update version of the package enter the command "Get -Package Updates", it will then display all the updatable packages.
Just see the example for updating the package. Here you will see the update of the jQuery package. We use the "Update-Package jQuery" command and the jQuery package will successfully update and it remove the oldest version of the jQuery.