How to Build NuGet servers and nuget servers on the Intranet
NuGet is a well-known tool for. NET programmers. It can directly install various public components in the open-source community, which can be said to be very convenient. However, in some cases, the company's internal public basic library and various projects are referenced, but cannot be released to the public NuGet server. Therefore, we need to set up a private service by ourselves, the public components used in various projects through NuGet are managed. It is very convenient. It also facilitates component version management.
I. NuGet website construction
1. Create an empty ASNET website
Note: To set the Framework to 4.6 or above, the NuGet. Server Library requires that the. net framework version be 4.6.
2. Use NuGet to install the "NuGet. Server" Library for NuGetServer. After the installation is successful, your Solution will become such a structure. And you do not need to write any code or change any configuration. It can run. Run this website. If you see the following welcome page, the website has been built. Note: There is only one readme.txt in packages. this directory is used to store the NuGet package. Click here to connect to view the existing package.
3. Deploy the website
This is exactly the same as deploying any ASP. NET Website. I will not elaborate here.
2. Package the code into a NuGet package
1. Go to the Nuget website to download the nuget command line tool,
: Https://www.nuget.org/downloads
2. Package with Nuget
There are two Nuget packaging methods:
A: directly package the dll through the project file:
1. Create a class library and compile it. Copy the downloaded nuget.exe file to the folder where the project file is located:
2. Create the nuget package: nuget.exe pack through the command line.
B: Use the nuget spec file for packaging ,.
1. In the same example, place the DLL to be packaged with nuget.exe in a directory and use the nuget spec command to create a nuspec file:
2. Open the Package. nuspec file to customize some configurations ,.
Note:$description$
UseAssemblyDescriptionAttribute
Before generating a package, you must compile the project first. Otherwise, a prompt is displayed.$description$
The error cannot be found;
3. Use the NuGet pack to pack it into the Nuget package:
Now the package is complete.
3. Upload the NuGet package to the server
Copy the packaged. nupkg file to the Package directory of the Nuget server in step 1. You can write a file upload function in the Nuget service to reduce the copy trouble.
4. Configure Visual Studio
The Nuget service has been set up successfully. Next we need to configure the NuGet source in VS so that other projects can use our NuGet server. Choose tools> Nuget Package Manager> package management console, and click the configuration icon:
Add and set the local NuGet source name and address. Note: source is/nuget
After that, our VS can install the NuGet package from the private server.
5. Use it in other projects
So far, the NuGet server has been configured, and the packaging of class libraries and DLL files has been completed. How can we reference the packages in the Intranet NuGet server in the project? The steps are as follows:
1. Create an NuGetTest project, and then use the tool-> Nuget package Manager-> package management console. On the command line: install-package IKSDK
2. Finally, let's look at the effect:
Now, the process of building an NuGet server on the Intranet is complete ,,