Managing the global packages, cache, and temp folders

Whenever you install, update, or restore a packet, NuGet manages packages and package information in several folders outside of your project construction:

Name Description and Location (per user)
global-packages The global-packages folder is where NuGet installs any downloaded package. Each parcel is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always apply packages directly from this folder. When using the packages.config, packages are installed to the global-packages binder, and so copied into the project's packages binder.
  • 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 simply). The environs variable takes precedence over the configuration setting.
http-cache The Visual Studio Parcel Director (NuGet iii.x+) and the dotnet tool store copies of downloaded packages in this cache (saved equally .dat files), organized into subfolders for each package source. Packages are not expanded, and the cache has an expiration time of 30 minutes.
  • Windows: %localappdata%\NuGet\v3-cache
  • Mac/Linux: ~/.local/share/NuGet/v3-cache
  • Override using the NUGET_HTTP_CACHE_PATH environment variable.
temp A binder where NuGet stores temporary files during its various operations.
  • Windows: %temp%\NuGetScratch
  • Mac/Linux: /tmp/NuGetScratch
  • plugins-cache four.8+ A folder where NuGet stores the results from the operation claims request.
    • Windows: %localappdata%\NuGet\plugins-cache
    • Mac/Linux: ~/.local/share/NuGet/plugins-cache
    • Override using the NUGET_PLUGINS_CACHE_PATH environment variable.

    Note

    NuGet iii.5 and earlier uses packages-cache instead of the http-cache, which is located in %localappdata%\NuGet\Cache.

    Past using the cache and global-packages folders, NuGet generally avoids downloading packages that already be on the computer, improving the functioning of install, update, and restore operations. When using PackageReference, the global-packages folder also avoids keeping downloaded packages within projection folders, where they might be inadvertently added to source command, and reduces NuGet'due south overall bear on on computer storage.

    When asked to retrieve a package, NuGet commencement looks in the global-packages folder. If the exact version of package is not in that location, and then NuGet checks all non-HTTP package sources. If the packet is still not constitute, NuGet looks for the parcel in the http-cache unless yous specify --no-cache with dotnet.exe commands or -NoCache with nuget.exe commands. If the packet is not in the enshroud, or the cache isn't used, NuGet then retrieves the package over HTTP .

    For more information, see What happens when a parcel is installed?.

    Viewing folder locations

    Y'all can view locations using the nuget locals control:

                  # Brandish locals for all folders: global-packages, http cache, temp and plugins cache nuget locals all -listing                          

    Typical output (Windows; "user1" is the current username):

                  http-enshroud: C:\Users\user1\AppData\Local\NuGet\v3-enshroud global-packages: C:\Users\user1\.nuget\packages\ temp: C:\Users\user1\AppData\Local\Temp\NuGetScratch plugins-cache: C:\Users\user1\AppData\Local\NuGet\plugins-cache                          

    (packet-enshroud is used in NuGet 2.x and appears with NuGet 3.5 and before.)

    You can also view folder locations using the dotnet nuget locals command:

                  dotnet nuget locals all --list                          

    Typical output (Mac/Linux; "user1" is the current username):

                  info : http-cache: /home/user1/.local/share/NuGet/v3-enshroud info : global-packages: /home/user1/.nuget/packages/ info : temp: /tmp/NuGetScratch info : plugins-cache: /home/user1/.local/share/NuGet/plugins-cache                          

    To brandish the location of a single binder, use http-enshroud, global-packages, temp, or plugins-cache instead of all.

    Clearing local folders

    If you see package installation problems or otherwise desire to ensure that y'all're installing packages from a remote gallery, use the locals --articulate choice (dotnet.exe) or locals -clear (nuget.exe), specifying the folder to clear, or all to clear all folders:

                  # Clear the 3.x+ cache (apply either control) dotnet nuget locals http-cache --articulate nuget locals http-enshroud -clear  # Clear the ii.x cache (NuGet CLI 3.five and earlier only) nuget locals packages-enshroud -articulate  # Clear the global packages folder (employ either control) dotnet nuget locals global-packages --clear nuget locals global-packages -clear  # Clear the temporary cache (utilize either control) dotnet nuget locals temp --clear nuget locals temp -clear  # Clear the plugins enshroud (utilize either control) dotnet nuget locals plugins-cache --clear nuget locals plugins-cache -clear  # Clear all caches (utilise either command) dotnet nuget locals all --articulate nuget locals all -clear                          

    Any packages used by projects that are currently open in Visual Studio are not cleared from the global-packages binder.

    Starting in Visual Studio 2017, use the Tools > NuGet Package Manager > Packet Manager Settings menu command, then select Articulate All NuGet Cache(s). Managing the enshroud isn't before long available through the Bundle Manager Console. In Visual Studio 2015, use the CLI commands instead.

    NuGet option command for clearing caches

    Troubleshooting errors

    The post-obit errors tin can occur when using nuget locals or dotnet nuget locals:

    • Error: The procedure cannot access the file <packet> because it is being used by another process or Clearing local resources failed: Unable to delete one or more files

      One or more files in the folder are in use by some other procedure; for example, a Visual Studio project is open that refers to packages in the global-packages binder. Close those processes and try over again.

    • Error: Access to the path <path> is denied or The directory is not empty

      You lot don't have permission to delete files in the cache. Change the folder permissions, if possible, and attempt again. Otherwise, contact your system ambassador.

    • Fault: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

      Shorten the folder names and attempt over again.