DLL file--Let me Manage (ii)

Source: Internet
Author: User

I. Summary

Previous review: Previous Blog We talked about the meaning and function of DLL file, know its reusability , flexibility, low coupling, good scalability, use less resources and so on , and we also introduced how to Using NuGet to manage and use The DLL files we need, but also left a problem, that is, how to manage our own dll files with NuGet .

This issue: when we need to use the DLL file we wrote, we can right-click-Add Reference-Browse, and then find the appropriate DLL file, add.

But that's the problem, if we have more than one person using a DLL file at the same time, then we modified the file, how to ensure that all the people have changed? Do we have to change it once, send it all over again, and then each of them re-cite it?

Of course, this cannot be said to be not a solution, but our efficiency will be greatly reduced. So we need to have a tool to manage our DLL files in a unified way, so let's talk about how to manage our own DLL files with NuGet .

second, the release

(Suppose we have developed a class library at this point.)

1. Download NuGet.exe : Click the Open link. and put it in the same directory as the. csproj file. This is a good tool for packaging, which can package our project files.
2. Registration

Register an account on the NuGet website and verify that you have an API Key. We'll call it My_api_key. Registered Address: Click to open the link

3. Set the API Key. To prevent errors, use the start--vs2012--visual Studio tools--vs2012 developer command Prompt.
Enter the following command to set the NuGet API Key: nuget setapikey 'my_api_key' For example:nuget Setapikey 979b13f9-a56d-4e50-bfaa-0aa8a0af3979


, enter the system drive letter (G:) Where the class library resides, and enter the directory where the cd+. csproj file is located (for example, the second sentence), and enter the following:nuget setapikey 'my_api_key '

4. Modify the AssemblyInfo.cs file

Set the attribute version in our AssemblyInfo.cs file, and so on, use 1.0.0.0 for the first time. Save the settings and compile the entire project.

5. Generate the . nuspec file

At the command prompt, enter the directory where the. csproj file is located, run the NuGet spec command, and generate the. nuspec file, for example, I generated the ITOO.Library.EFBase.nuspec here.

6. Modify the. nuspec file

Open the. nuspec file that you just generated, for example, remove the useless (circled by the red box), and then the other items correspond to the one by one in the AssemblyInfo.cs file.


When you are finished modifying:

It is emphasized here that the above information is required, although this information can be read directly from the AssemblyInfo.cs file, but many times it is not read, so need handwriting, especially in the re-release.

7. Generate the . nupkg file

also at the command prompt, enter the. csproj file directory, enter the command to generate the class library package, in my case, the command is as follows: Nuget pack Itoo. Library.EFBase.csproj. After the successful generation of the. nupkg file, as I generated here itoo.library.efbase.1.0.0.0.nupkg


8. Publish the Class library package

last input command: NuGet push Itoo. Library.efbase.1.0.0.0.nupkg. You will be prompted to publish successfully.


Once this is generated, we can search for our published DLLs in NuGet and then select the references. Since the previous article has been introduced, so no more say

Third, update

If our DLL file has been modified and needs to be republished, we can follow the 4-8 steps above and then go to NuGet to search for the updated version. If there is a problem, you can refer to the NuGet Publishing class library, dependency issues



Summary: at this point, we have a simple understanding of DLL files, and the use of NuGet to manage our DLL files. But about DLL dynamic link library more in-depth knowledge we did not involve, but DLL does bring us a lot of convenience, at the same time it also tells us a kind of thought, object-oriented encapsulation, abstract thinking, we want to simplify the complex things, simple things packaged into a whole, This makes it very convenient for us to use them. From this we can see that our study is not only learning, but more importantly thinking about how to learn, I hope everyone in the study after the serious thinking.




DLL file--Let me Manage (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.