1

Can I change default nuget packages folder on Linux. I use dotnet restore and found that cache stored in ~/.nuget/packages. But it's not convenient for me.Thanks

Serhii Shemshur
  • 1,273
  • 3
  • 15
  • 21

1 Answers1

1

You can use the NUGET_PACKAGES env variable to do this, or you can specify --packages at the time you run dotnet restore. The env variable is undocumented, so there could be changes in the future. Here's a link to the relevant code in case that happens: https://github.com/dotnet/cli/blob/rel/1.0.0/build_projects/shared-build-targets-utils/Utils/Dirs.cs#L43

The output of dotnet restore --help will give you more details:

Arguments:
  [root]  List of projects and project folders to restore. Each value can be: a path to a project.json or global.json file, or a folder to recursively search for project.json files.

Options:
  -h|--help                       Show help information
  --force-english-output          Forces the application to run using an invariant, English-based culture.
  -s|--source <source>            Specifies a NuGet package source to use during the restore.
  --packages <packagesDirectory>  Directory to install packages in.
  --disable-parallel              Disables restoring multiple projects in parallel.
  -f|--fallbacksource <FEED>      A list of packages sources to use as a fallback.
  --configfile <file>             The NuGet configuration file to use.
  --no-cache                      Do not cache packages and http requests.
  --infer-runtimes                Temporary option to allow NuGet to infer RIDs for legacy repositories
  -v|--verbosity <verbosity>      The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error.
  --ignore-failed-sources         Only warning failed sources if there are packages meeting version requirement

I would also recommend reading up on this question if you are trying to go for offline development: How do you set up for offline development with .net Core

Community
  • 1
  • 1
Joel
  • 307
  • 3
  • 7