What is NuGet ?(C# Interview questions with answers)


In this video we will try to understand what exactly is NuGet and why do we need it The amount of Frameworks and libraries from both Microsoft and Non-Microsoft open sources are huge in numbers From Microsoft we have MVC we have Entity Framework lot of those set ups and libraries which comes separate From open sources we have NUnit log4net etc As a Visual Studio Developer If you want neat reference this frameworks or libraries what you need to you do is You need to search the Library first thing Second thing you need to install the Library or propably Unzip at some place Then reference the DLL in your Visual Studio Project If the library demands We have to make changes to the app config file or web config file In case if you want to remove that library from your Visual Studio project You have to revert by your config changes Un reference the DLL Uninstall the Library etc You can easily visualize how difficult it is to add references to these libraries The complete thing becomes more complicated when you have newer version of these frameworks and libraries It is very difficult to track which URL the set up is what kind of DLL to reference and Unreference what kind of changes to be made to Config Files etc That’s exactly where NuGet come into picture NuGet is nothing but its a Visual Studio extension which helps us to search libraries it help us to locate those libraries You can download them reference them in your Visual Studio project Automatically NuGet will make a appropriate changes to the app config file and web config file depending on what libraries you have downloaded Let me show you a simple demo of how to go and reference NUnit in your project by using the NuGet extension Here is the simple class library project I have Actually this class library project is nothing but its a test project I am going to write this test case in NUnit I would like to use NuGet download NUnit reference it in my project I have no idea where to get NUnit from I have no idea what DLLs to reference I have no idea what config files to modify No worries There where NuGet comes into picture First thing click on project you can see there is a menu here saying manage NuGet packages Click on that search for NUnit I’ll just go online and start searching for Nunit it is searching where NUnit is because I have searched for NUnit He has also given me other setups as well but I am interested in only this NUnit Unit testing Framework click install here it is installed close this If you see here in your Visual Studio project you can see that he has reference NUnit.framework dll In other words it went ahead it downloaded the DLL into your project folder It also added a reference to your class library I just need to go and say here NUnit.framework and start attributing My Test cases My test methods I don’t have to go to Google now anymore Search where NUnit is Install it add a reference to my DLL worry about lot of things and the good part is here in case you want to uninstall it you want to dereference the whole thing what you can do is you can just go to project manage NuGet packages Look at your package I am going to say tell me what packages are there currently with me I have this NUnit I can go here in my install packages and I can Uninstall this If I Uninstall this again it will dereference the DLL remove all the changes that has been done to the app config file ensure that your project has no more reference to this DLL If I click on uninstall If I close it you can see lot of errors are popping up because the NUnit framework is no more referenced If you see the class library solution explorer you can see that the NUnit DLL is no more referenced Again revising NuGet is nothing but it’s a Visual Studio extension Which will help you to search locate the library download them reference them in your VS project also if you want it you can again revert back the changes by using NuGet If you have a complicated framework must be open source or probably coming directly from Microsoft At least first search in NuGet if it is there then you don’t need to do many things manually I hope that you enjoyed this video In this video we were trying to understand what is NuGet and do we need it Thank You So Much

Posted in Uncategorized
Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *