In project development, we often use third-party libraries, which can be called by downloading references, or by downloading public plugins through the NuGet official website.
nuget address:The hyperlink login is visible.
Nuget is an open-source project under the .NET platform, which is an extension of Visual Studio. When developing applications based on the .NET Framework using Visual Studio, Nuget makes adding, removing, and updating references in your project much faster and easier. This is the definition in Wikipedia, in fact, Nuget is a package manager, similar to Java's Maven, which can help us manage dlls more conveniently. The nuget official website is a public class library, and if you upload your own class library, it will also be provided to others to download and install calls. Since projects developed by companies and teams involve trade secrets or privacy, we do not want to release them publicly, so we need to build a private NuGet repository by ourselves.
Nuget private repositories
First, create a new asp.net web application and select an empty template NugetDepot (.NET 4.7.2) project.
The project installs the Nuget.Server package with the following command:
Each package is licensed to you by its owner. NuGet is not responsible for third-party packages and does not license them. Some packages may include dependencies that are subject to other licenses. Click on the package source (source) URL to determine any dependencies.
Package Manager console host version 5.4.0.6292
Type "get-help NuGet" to see all available NuGet commands.
PM> Install-Package NuGet.Server -Version 3.4.1
Attempts are being made to collect and target ". NETFramework, Version=v4.7.2" of the project "NugetDepot" and the dependency information of the package "NuGet.Server.3.4.1" It took 5.33 sec to collect dependency information Trying to resolve the dependency of package "NuGet.Server.3.4.1" with DependencyBehavior as "Lowest" Parsing dependency information takes 0 ms Parsing the operation to install package "NuGet.Server.3.4.1" Operation resolved to install package "NuGet.Server.3.4.1" GETThe hyperlink login is visible. GETThe hyperlink login is visible. GETThe hyperlink login is visible. GETThe hyperlink login is visible. OKThe hyperlink login is visible.197 ms Microsoft.Data.Edm 5.8.4 is being installed. OKThe hyperlink login is visible.790 ms NuGet.Core 2.14.0 is being installed. OKThe hyperlink login is visible.1100 ms Microsoft.Web.Xdt 2.1.1 is being installed. OKThe hyperlink login is visible.3627 ms NuGet.Server.Core 3.4.1 is being installed. GETThe hyperlink login is visible. GETThe hyperlink login is visible. OKThe hyperlink login is visible.171 ms System.Spatial 5.8.4 is being installed. OKThe hyperlink login is visible.179 ms Microsoft.Data.OData 5.8.4 is being installed. GETThe hyperlink login is visible. OKThe hyperlink login is visible.617 ms Microsoft.AspNet.WebApi.OData 5.7.0 is being installed. GETThe hyperlink login is visible. GETThe hyperlink login is visible. Retrieve package "Microsoft.AspNet.WebApi 5.2.3" from "nuget.org" Retrieve package "Microsoft.AspNet.WebApi.Client 5.2.3" from "nuget.org" Retrieve package from "nuget.org" for "Microsoft.AspNet.WebApi.Core 5.2.3" Retrieve package "Microsoft.AspNet.WebApi.OData 5.7.0" from "nuget.org" Retrieve package "Microsoft.AspNet.WebApi.WebHost 5.2.3" from "nuget.org" Retrieve package "Microsoft.Data.Edm 5.8.4" from "nuget.org" Retrieve package "Microsoft.Data.OData 5.8.4" from "nuget.org" Retrieve package "Microsoft.Web.Infrastructure 1.0.0" from "nuget.org" Retrieve package "Microsoft.Web.Xdt 2.1.1" from "nuget.org" Retrieve package "Newtonsoft.Json 9.0.1" from "nuget.org" Retrieve package "NuGet.Core 2.14.0" from "nuget.org" Retrieve package "NuGet.Server 3.4.1" from "nuget.org" Retrieve package "NuGet.Server.Core 3.4.1" from "nuget.org" Retrieve package "NuGet.Server.V2 3.4.1" from "nuget.org" Retrieve package "System.Spatial 5.8.4" from "nuget.org" Retrieve package "WebActivatorEx 2.2.0" from "nuget.org" GETThe hyperlink login is visible. Adding package "Microsoft.Data.Edm.5.8.4" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.Data.Edm.5.8.4" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" OKThe hyperlink login is visible.484 ms WebActivatorEx 2.2.0 is being installed. Added package "Microsoft.Data.Edm.5.8.4" to "packages.config" Microsoft.Data.Edm 5.8.4 has been successfully installed to NugetDepot Adding package "Microsoft.Web.Infrastructure.1.0.0" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.Web.Infrastructure.1.0.0" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.Web.Infrastructure.1.0.0" to "packages.config" Microsoft.Web.Infrastructure 1.0.0 has been successfully installed to NugetDepot Adding package "Microsoft.Web.Xdt.2.1.1" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.Web.Xdt.2.1.1" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.Web.Xdt.2.1.1" to "packages.config" "Microsoft.Web.Xdt 2.1.1" has been successfully installed to NugetDepot Adding package "Newtonsoft.Json.9.0.1" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" OKThe hyperlink login is visible.1030 ms NuGet.Server 3.4.1 is being installed. Package "Newtonsoft.Json.9.0.1" has been added to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" OKThe hyperlink login is visible.1216 ms NuGet.Server.V2 3.4.1 is being installed. Added package "Newtonsoft.Json.9.0.1" to "packages.config" Script file "C:\Users\itsvse_pc\source\repos\NugetDepot\packages\Newtonsoft.Json.9.0.1\tools\install.ps1" "Newtonsoft.Json 9.0.1" has been successfully installed to NugetDepot Adding package "Microsoft.AspNet.WebApi.Client.5.2.3" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.AspNet.WebApi.Client.5.2.3" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.AspNet.WebApi.Client.5.2.3" to "packages.config" "Microsoft.AspNet.WebApi.Client 5.2.3" has been successfully installed to NugetDepot Adding package "Microsoft.AspNet.WebApi.Core.5.2.3" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.AspNet.WebApi.Core.5.2.3" has been added to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.AspNet.WebApi.Core.5.2.3" to "packages.config" "Microsoft.AspNet.WebApi.Core 5.2.3" has been successfully installed to NugetDepot Adding package "Microsoft.AspNet.WebApi.WebHost.5.2.3" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.AspNet.WebApi.WebHost.5.2.3" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.AspNet.WebApi.WebHost.5.2.3" to "packages.config" "Microsoft.AspNet.WebApi.WebHost 5.2.3" has been successfully installed to NugetDepot Adding the dependency-only package "Microsoft.AspNet.WebApi.5.2.3" to the project "NugetDepot". Adding package "Microsoft.AspNet.WebApi.5.2.3" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.AspNet.WebApi.5.2.3" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.AspNet.WebApi.5.2.3" to "packages.config" "Microsoft.AspNet.WebApi 5.2.3" has been successfully installed to NugetDepot Adding package "NuGet.Core.2.14.0" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "NuGet.Core.2.14.0" has been added to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "NuGet.Core.2.14.0" has been added to "packages.config" NuGet.Core 2.14.0 has been successfully installed to NugetDepot Adding package "NuGet.Server.Core.3.4.1" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "NuGet.Server.Core.3.4.1" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "NuGet.Server.Core.3.4.1" to "packages.config" NuGet.Server.Core 3.4.1 has been successfully installed to NugetDepot Adding package "System.Spatial.5.8.4" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "System.Spatial.5.8.4" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "System.Spatial.5.8.4" to "packages.config" System.Spatial 5.8.4 has been successfully installed to NugetDepot Adding package "Microsoft.Data.OData.5.8.4" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.Data.OData.5.8.4" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.Data.OData.5.8.4" to "packages.config" Microsoft.Data.OData 5.8.4 has been successfully installed to NugetDepot Adding package "Microsoft.AspNet.WebApi.OData.5.7.0" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "Microsoft.AspNet.WebApi.OData.5.7.0" has been added to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "Microsoft.AspNet.WebApi.OData.5.7.0" to "packages.config" "Microsoft.AspNet.WebApi.OData 5.7.0" has been successfully installed to NugetDepot Adding package "NuGet.Server.V2.3.4.1" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "NuGet.Server.V2.3.4.1" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "NuGet.Server.V2.3.4.1" to "packages.config" NuGet.Server.V2 3.4.1 has been successfully installed to NugetDepot Adding package "WebActivatorEx.2.2.0" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "WebActivatorEx.2.2.0" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Added package "WebActivatorEx.2.2.0" to "packages.config" WebActivatorEx 2.2.0 has been successfully installed to NugetDepot Adding package "NuGet.Server.3.4.1" to folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "NuGet.Server.3.4.1" has been added to the folder "C:\Users\itsvse_pc\source\repos\NugetDepot\packages" Package "NuGet.Server.3.4.1" has been added to "packages.config" NuGet.Server 3.4.1 has been successfully installed on NugetDepot Performing a NuGet operation takes 19.54 sec Time Elapsed: 00:00:25.0831394 PM> He will automatically modify the web.config file and add files such as NuGetODataConfig.cs.
We need to modify the followingweb.configfile, update to the options you need, and configure them as follows:
At the same time, we also need to modify the NuGetODataConfig.cs file, and when the program starts, create a path to store nuget, which is not recommended to be placed under a folder in the root directory of the website.
We put the nuget package under the E:\nuget_packages directory with the code:
Try launching the website as shown below:
Push to a private repository
Let's create a new netstandard2.0 library project, and at the same time, write some code to test (below), right-click on the project and click the "Package" button, it will be generated under the C:\Users\itsvse_pc\source\repos\NugetDepot\ClassLibrary2\bin\Debug directoryClassLibrary2.1.0.0.nupkgfile
Need to be fromThe hyperlink login is visible.Download the Nuget Windows x86 Commandline tool "nuget.exe".
Try the following command to push the nuget package to our newly created private repository.
For additional commands, see the documentation:The hyperlink login is visible.
Install the private package
In VS Dev Tools, add the NuGet package source as shown in the image below:
Create a new .Net Core 3.1 console project, install the nuget package we uploaded, and use the following command:
Finally, attach the source code download:
Tourists, if you want to see the hidden content of this post, please Reply
|