For a C# Console application in VS2019 I issued the following command from .NET CLI (Developer PowerShell):-
dotnet add package <PackageName> --version <Version>
Then from Object Browser I discovered that the package assembly (.dll) has been copied into my local path starting with C:\Users<userid>.nuget\packages<PackageName><Version>. But if I see my project definition (.csproj file) I only see package name and not the path:-
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="<PackageName>" Version="<Version>" />
</ItemGroup>
</Project>
Where is the setting in Visual Studio (or .dotnet CLI) that decides which local path NuGet packages should get downloaded to ?
This is the global NuGet cache, it's configurable (as per the quoted docs below) but yours is the default location
The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder. When using the packages.config, packages are installed to the global-packages folder, then copied into the project's packages folder.
Windows: %userprofile%.nuget\packages
Mac/Linux: ~/.nuget/packages
Override using the NUGET_PACKAGES environment variable, the globalPackagesFolder or repositoryPath configuration settings (when using PackageReference and packages.config, respectively), or the RestorePackagesPath MSBuild property (MSBuild only). The environment variable takes precedence over the configuration setting.