Use Nuget to manage dll and nuget to manage dll

Source: Internet
Author: User

Use Nuget to manage dll and nuget to manage dll

Preface

Nuget is no longer a new thing. It is an extension tool of vs, which makes adding, deleting, and updating references in projects more convenient and convenient. Nowadays, many traditional companies still lag behind in dll management, and some even send dll files. The direct disadvantage of this is that it is cumbersome and error-prone. I have tried a dll version before. When the tester updates the dll to the online interface, it goes down. Then, it takes a bunch of time to locate the problem. Nuget allows us to easily manage references and reduce unnecessary troubles. Next we will illustrate how to build your own nuget database on your computer, internal server, or nuget server. This article does not have any advanced information, but only provides reference for new users.

Build a package Server

1. Install nuget

This is simple. If your vs does not exist, it won't work. Click Tools> extensions and updates to search for nuget to install Nuget. After installation, right-click the project and choose manage nuget package, here we can install the required references, such as EF, Newtonsoft, and jQuery. The following [package management console] can be installed and referenced through commands, and the operations on the interface are the same.

  

2. Build an nuget Server

The nuget server is actually a site that obtains the required package through a request. So what we need to do is to build a web site.

Create an asp.net mvc project and enter Install-Package Nuget in the [Package Manager Console. server-Version 2.11.1 you can install nuget services. After installation, our project will have more files, web. you can also overwrite the config. We don't need to worry about what we do.

2.1 need to pay attention to is, here Nuget. Server has a certain degree of dependency, so we want to select the appropriate version, the specific can be seen here: http://www.nuget.org/packages/NuGet.Server/2.11.1

2.2 web. config configuration. After the installation is successful, the following configuration items will be added:

<Add key = "requireApiKey" value = "true"/> indicates whether apiKey is required to upload a package to the server, which is generally true.

<Add key = "apiKey" value = ""/> can be considered as a key, which is used when uploading a package.

<Add key = "packagesPath" value = ""/> package location. The default value is ~ /Packages

<Add key = "allowOverrideExistingPackageOnPush" value = "false"/> set whether to overwrite existing packages to true.

  

2.3 After installation, you can directly publish the website to iis. That's right, it's that simple !!!

3. Add the nuget service to the nuget management tool

Choose tools> library Package Manager> Package Manager settings, and add the service site we created here.

3.1 pay attention to the/nuget path. For details, refer to the route code of the site.

At this time, right-click [Reference] [manage Nuget package] To see the newly added service. Next, we need to put the package in this service.

4. Write a dll and upload it to the server.

We can compile a dll and use the Package Manager NuGetPackageExplorer to publish it. Here is a practical package management tool.

4.1 create a Package Metadata in NuGetPackageExplorer [Edit]-> [Edit Metadata]. You can enter some dll information here. You may be familiar with it, if our dll has other dependencies, you can add them here. Among them, Id is more important, that is, we need to use during installation, that is, Install-Package XXX here XXX.

4.2 right-click the work area on the right to add a Lib folder, and then add the newly compiled dll

4.3 save. At this time,. the nupkg file can be viewed as a compressed file. nuget is used to parse it to obtain the actual dll file. We actually need this file and do not need a specific dll. Next, go to [File]> [publish]. By default, it is published to the nuget official website. We need to register an account to get the key, but we can also choose the site we created above, the key is the key of the configuration file.

A Not Allowed error may occur here. We need to go to [Service Web site]> [module], find [WebDAVModel], and delete it.

4.4 After the release is successful ~ The/Packages directory shows the changes. Next, you can use Nuget to add references from our own server just like adding other references. You can also use the command Install-Package TestNugetServerDll to Install Nuget.

Summary

There are also some pitfalls. Just step on to solve the problem. Baidu also has a lot of information.

Related Article

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.