Saturday, April 2, 2011

NuGet

What is NuGet?
                                                      
        NuGet is a package manager for .Net. Using this you can search the packages and add it in to your project very easily.


      How can I install NuGet?
                   Installing of NuGet is very simple, Now NuGet is available as a VS Extension. You can install NuGet very quickly.
                   Tools -> Extension Manager ->
and search NuGet and Install it.



How can I Add a Package using NuGet?
             Adding Packages for our Project is very simple using NuGet.

right click on References and Select Add Library Package Reference Option. This will shows an add Libraypackage window from this you can search your package and install it in to your project using a single click(also uninstall by a single click) or you can select it in Project menu
Project -> Add Library Package Reference



Here I'm going to add ELMAH(Error Logging Modules and Handlers)  package reference.


   After Installing ELMAH package reference you can see the Elmah reference at the reference folder
Also NuGet added a new configuration file package.config and made some changes in web.config to work ELMAH

Automatically generated Package.config contents


                                 Here is the automatically created changes in web.config



Here is the elmah.axd view where we can see the logged errors

If you want to remove the ELMAH, you can simply do it by selecting uninstall option
after uninstalling elmah NuGet will remove all added references and files (Package.config file and changes in web.config etc)
You can create your own package for your company framework or other requirement. I will explain it in my next blog post.

Read More about Nuget:
Microsoft opened a Nuget gallery http://nuget.org. This site allows anyone to search and browse a online gallery of  open source packages availble via NuGet.
Read more from  Phill Haack  and  Scott Hanselman blog posts


0 comments:

Post a Comment