Simply said, the different NuGet tools typically create a reference to a package in the project file or packages.config, then perform a package restore, which effectively installs the package. The exception is nuget install, which only expands the package into a packages folder and does not modify any other files.
The general process is as follows:
(All tools except nuget.exe) Record the package identifier and version into the project file or packages.config.
If the installation tool is Visual Studio or the dotnet CLI, the tool first attempts to install the package. If it's incompatible, the package is not added to the project file or packages.config.
If the package is not in the global-packages folder, attempt to retrieve it from the sources listed in the configuration files. Package Source Mapping configurations are applied at this point. For online sources, attempt first to retrieve the package from the HTTP cache unless -NoHttpCache is specified with nuget.exe commands or --no-http-cache is specified with dotnet restore. (Visual Studio and dotnet add package always use the cache.) If a package is used from the cache, "CACHE" appears in the output. The cache has an expiration time of 30 minutes.
If the package has been specified using a floating version, or without a minimum version, NuGet will contact all sources to figure out the best match.
Example: 1.*, (, 2.0.0].
If the package is not in the HTTP cache, attempt to download it from the sources listed in the configuration. If a package is downloaded, "GET" and "OK" appear in the output. NuGet logs http traffic on normal verbosity.
If the package cannot be successfully acquired from any sources, installation fails at this point with an error such as NU1103. Note that errors from nuget.exe commands show only the last source checked, but implies that the package wasn't available from any source.
When acquiring the package, the order of sources in the NuGet configuration may apply:
NuGet checks sources local folder and network shares before checking HTTP sources.
If downloaded, install the package into the per-user global-packages folder. NuGet creates a subfolder for each package identifier, then creates subfolders for each installed version of the package.
NuGet installs package dependencies as required. This process might update package versions in the process, as described in Dependency Resolution.
Update other project files and folders:
For projects using PackageReference, update the package dependency graph stored in obj/project.assets.json. Package contents themselves are not copied into any project folder.
Create a .NET project and learn to add packages and manage package dependencies in your project. Use the .NET Core CLI and NuGet registry to add libraries and tools to your C# applications through Visual Studio Code.