In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to restore the package of nuget". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to restore the package of nuget"!
How to restore the Intro of a package by nuget
It has always been simple to use the nuget package. Recently, if you want to toss about something, you need to parse the nuget package yourself. The user specifies the name and version of the nuget package, and then parses the corresponding nuget package and adds a reference to the project. So I want to figure out how the nuget package is restored and how to find the nuget package that has been downloaded locally.
Reference to the Nuget package
For dotnetcore projects (not counting previous project.json projects, only projects like * .csproj are discussed), they all use the new project format, the PackageReference pattern.
Example:
For dotnet framework projects, if the PackageReference package format is the same as above, and if it is in the traditional packages.config package format, there will be a packages.config file containing the referenced nuget package. Example of the file content:
This paper mainly explains the form of dotnetcore, which is PackageReference.
Restore of nuget package
After the nuget package is downloaded for the first time from nuget.org or your own package source, it will be stored in a local folder, and the next time you need the same version of the package restore, it will be obtained directly from the local package. This saved folder is part of the nuget configuration. You can find some changes to the location where nuget saves the packages folder by default on the Internet, but these articles are very similar. It only gives a solution, but it does not say why, and the basis for doing so is not explained. In fact, this solution adds a default nuget configuration file and modifies the location where the nuget package is saved.
Nuget configuration default configuration
Nuget will have some default configurations. You can refer to the official document: https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section
There is a globalPackagesFolder configuration in the nuget configuration, which is used to specify the default location where the nuget package is saved. The default location on Windows is% userprofile%\ .nuget\ packages, and the default location on Linux/Mac is ~ / .nuget / packages. You can use the nuget.config or NuGet.Config configuration file to modify the default save file. In addition, you can also configure NUGET_PACKAGES to modify the location of the default nuget package by way of environment variables.
Default profile
Default configuration file for nuget, official document: https://docs.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-config#options
The location of the default configuration file on Windows is% AppData%\ NuGet\ NuGet.Config, which is also the most common solution used to modify the default location of nuget packages on the Linux/Mac. Most of them are ~ / .config / NuGet/NuGet.Config, and some may be ~ / .config (related to the system version).
This configuration file is not available by default on Windows. After adding this default configuration file, it will work globally.
Create the default configuration file% AppData%\ NuGet\ NuGet.Config, and then configure globalPackagesFolder in this configuration file to modify the default nuget package save path
Example:
At this point, I believe you have a deeper understanding of "how to restore the package of nuget". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.