Download Nuget.Server

Search for Nuget. Server from the official Nuget server and click the Github path in the project URL. Download nuget. Server from Github.

The file path after downloading and decompressing is as follows:

Build Nuget.Server

  1. Open the project file nuget.server. SLN, go to Nuget.server, right-click to publish, and select File System (just like publishing web applications, publish to IIS).

  2. IIS creates a new site, MyNuGet



    If the following page is displayed during startup, the setup is successful

  3. Note: if you click here, a 404 page will appear as shown below



    This can be done by running the Nuget.Server project with VS and replacing the bin directory under IIS with the bin directory. The following figure represents successful setup

    Open VS Nuget Manager and click on the Settings icon to create our own Nuget server

    Then we can connect to the server we built ourselves

Iii. Basic use of self-built NuGet

  1. Download NuGet command line packaging tool NuGet. Exe at www.nuget.org/downloads
  2. Package our program

Method 1: Package the csPROj class library file

First, open the file AssemblyInfo.cs to modify the assembly information

Use nuget. Exe to package the assembly

Run the spec command in the. Csproj file directory

nuget.exe spec //spec executes commands in the. Csproj file directory
Copy the code



This will generate a.nuspec file, open that file

Modify the XML properties of assemblyInfo.cs (note that some of this information is best matched to the assembly information in AssemblyInfo.cs)

Run the pack command after the modification is complete

Copy the generated. Nupkg file directly to the Packages folder in the IIS directory of the Nuget server

It can also be pushed to the Nuget server with the push command

nuget push *.nupkg -s http:127.0.0.1:8005 123456 // Push package path option address APIkey
// ApiKey can be configured in the server webconfig
Copy the code

When you’re done, you can view or use our published assemblies

Four, problem,

  1. At the beginning of the use of the nuget package often due to mistakes or program problems resulting in the need to re-release, but found that after overwriting the original program, the updated project is still the original program. Solution: Carefully and carefully package, need to re-release the package can be upgraded, not overwrite. (thought it was only an upgrade, not an overlay)
  2. After a period of time, the technical solution of Nuget management package was provided at that time, but there was no corresponding usage specification and system, which led to the confusion of nuget package in the team. Developers randomly upgraded and referenced Nuget package, and finally caused a big problem one day. Therefore, it is necessary to develop a perfect use standard and system, including how to package, how to release, who to package, who to release, carefully package, upgrade, special management, etc.
  3. Because of the problems caused by problem 2, we decided to rearrange the Nuget package (unbreakable), so we rebuilt a Nuget server, reorganized the existing assemblies, components, repackaged and distributed, but found that after migrating to a new one, the downloaded assemblies in the project were still the same. (Again encountered problem 1). This time the inspiration was to find a solution to the problem. VS2017 clears all NuGet caches using tools -> Options ->

    Download the package again to solve the problem



    If you don’t have VS2017 or can’t find NuGet cache options, you can also find your machine’s NuGet cache folder and delete the corresponding contents, usually in C:\Users\Administrator. NuGet