Monday, January 20, 2014

Using Install Package commands within Package Manager console

The moment I decided to get started with my new MVC project, NuGet package manager is the best bet to go further and install  Entity Framework, Web Optimization, MVC etc.

   Though there is a UI driven option, but also another way to do it through console is what I had been doing ( and I prefer that way).  Listing few options that I used to install from package manager console.

 For installing Entity framework, you could use the below one :

PM> Install-Package EntityFramework

The above might install a version more later than the one you might need. For example, when you need Entity Framework 4.3.1, but the latest is 6, you can still get a specific version by typing the following...

PM> Install-Package EntityFramework -Version 4.3.1


Using the -Version will help for all the nu-get packages that needs to be installed specifically... In this case, this might not work, since we have a latest version already installed, to fix this, we need to do a force uninstall and then install specific version as below...

PM> Uninstall-Package EntityFramework -force

PM> Install-Package EntityFramework -Version 4.3.1

Similarly, for Web API, you could do the following.

PM> Install-Package Microsoft.AspNet.WebApi

For specific version of Newton-soft Json (using json in our project)

PM> Install-Package Newtonsoft.Json -Version 4.5.6

To use the help option and to view list of commands..

PM> get-help Nuget

To get a list of all available packages

PM> Get-package -ListAvailable

   Running the above is going to take a lot of time, as the number of available packages will be more... You can try a restricted search based on a specific package as below.

PM> Get-Package -ListAvailable -Filter EntityFramework

In the above case, we are listing only EntityFramework related packages, thus narrowing the amount of items we need to go through.



No comments:

Post a Comment