There has been a lot of experience with introduction and use of the NuGet garden, and this article is only a record of studying nuget as a self-study.
The first time I met NuGet was when I upgraded the project to MVC3 last year, when I saw a tool menu with one more library package Manager, right-click Project file more than one manage Nuget Packages ..., this is a god horse thing, it was confused, Backstage to find out some information to know that NuGet is an extension of Visual studio, referring to Dudu is the management program's package, you can refer to this article on MSDN using NuGet to manage the project library and our blog Park webmaster Dudu written by programmers, Manage your library with NuGet, some similar to the common maven in Java
Why to use NuGet
Simply put NuGet can be our job more convenient, when we have to refer to some of the library in the project, such as jquery, Newtonsoft.json, log4net, etc., we need to download these libraries from the Internet, and then copied to each project, When there are updates to the class library and have to repeat it is cumbersome, then you can consider using NuGet to help us manage and update these class libraries, and update the class library will automatically add the relevant reference to the class library, very convenient. Of course, some of our commonly used class library update frequency is not very high and even if the new version we do not need to always keep up to date, so this helps us more limited, personally think that the biggest advantage of NuGet is to build their own class library server, think about it, in some larger companies have a lot of projects, Then some of them are the entire group, or even the entire company general-purpose class library, when these libraries have updated we need to copy to our project, even sometimes we do not know whether the version of the project is consistent, sometimes occasionally one or two items forgot to copy the update there are inexplicable errors, for this headache, Now with NuGet, the world is different.
Installing the NuGet Extension
To use NuGet, you need to install it first (NuGet is automatically installed on a system with MVC3 installed)
1. Click on the Tools--Extension Manager (R) ...--> the upper right corner of the search box to enter NuGet
2. Click the download button above the Nugetpackage Manager entry to start the download of NuGet
3. The installation page appears after the download is complete, click Install to start the installation
4. The installation is complete soon, then click Close to complete the installation
5. After the installation, NuGet is temporarily unavailable, need to restart the next vs just line, after the restart after the completion of the Extension Manager (R) ... In the installed extensions you can see that the NuGet Package Manager is installed
Download the required class library using NuGet
1. Open the NuGet management interface
2. The following screen appears, you can find the library you want in the top-right corner of the search in the input keywords to find their own class library, find the right class library post install installation
3. Here we choose to install the Json.NET, click on the installation of the component download interface
4. When the download is complete, you will be prompted to install the class library to what project, here we choose to install to the TestConsole project
5. When the installation is complete, you can see that the installed Josn.net shows an installed small tick
6. Open the project reference to see the class library that we just selected Newtonsoft.json has been automatically added to the project reference
Manage your class library using the command line
1. NuGet provides a command line installation method, select Package Manager console from the menu, open the command line console
2. The NuGet console interface appears, the default class library source (package source) is the official site, or you can point to your own local or internal site point, default project means that the downloaded class library is added to the reference of that project
3. The NuGet console has several common commands
Get-package gets the class library that is already installed for the current project
Install-package Install the specified class library, the command format is as follows: Install-package class Library ID, such as install-package Newtonsoft.json It is important to note that the ID of the class library is unique, When you point to a command, the specified ID class library is automatically searched for the specified class library source, and if found, it is automatically downloaded and added, and you cannot find a prompt to find the class library.
Uninstall-package unload the specified class library with the following command format: Uninstall-package class Library ID, such as Uninstall-package Newtonsoft.json
Update-package updates the specified class library with the following command format: Update-package class Library ID, such as Update-package Newtonsoft.json
PS: Initially unfamiliar when you can use the interface to download and update the class library, have some experience or recommend the use of the console to add, update class library This is convenient, because using the console need to know the exact ID of the class library, you can go to http://www.nuget.org/packages here to find , record their usual ID for easy use later
The next article details how to build your own NuGet server from scratch and publish your own class library to the server.
NuGet Learning Notes (1)--initial nuget and quick installation use