Logo

dev-resources.site

for different kinds of informations.

How to change default Nuget packages folder on Windows

Published at
5/16/2023
Categories
csharp
nuget
Author
tombohub
Categories
2 categories in total
csharp
open
nuget
open
Author
8 person written this
tombohub
open
How to change default Nuget packages folder on Windows

The default folder where C# solutions will save the nuget packages is %UserProfile%\.nuget\packages .

To change to different one there are 2 options:

Add config to NuGet.config file:

File locations is %APPDATA%\NuGet\NuGet.config for user specific, or %ProgramData%\NuGet\NuGet.config if it's global installation.

Add globalPackagesFolder settings. I was confused by repositoryPath after googling which is different thing! Do not be confused, use globalPackagesFolder setting!

You add settings in config section like this:

  <config>
    <add key="globalPackagesFolder" value="D:\YourFolderPath" />
  </config>
Enter fullscreen mode Exit fullscreen mode

so whole config file should look something like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="True" />
  </packageManagement>
  <config>
    <add key="globalPackagesFolder" value="D:\YourFolderPath" />
  </config>
</configuration>
Enter fullscreen mode Exit fullscreen mode

Adding NUGET_PACKAGES env variable:

Google in order to see how to do it: google search

After that run command in terminal dotnet nuget locals -l all
and you should see your new folder in global-packages:

http-cache: C:\Users\ME\AppData\Local\NuGet\v3-cache
global-packages: D:\YourFolderPath
temp: C:\Users\ME\AppData\Local\Temp\NuGetScratch
plugins-cache: C:\Users\ME\AppData\Local\NuGet\plugins-cache
Enter fullscreen mode Exit fullscreen mode
nuget Article's
30 articles in total
Favicon
Simplifying Dependency Management with NuGet Central Package Management
Favicon
Failed to access Nuget in China
Favicon
Seu Primeiro Pacote NuGet: Um Passo a Passo Prático
Favicon
Central Package Management in .NET - Simplify NuGet Dependencies
Favicon
Custom NET8 Entity Framework Core Generic Repository
Favicon
How to publish a package on Nuget.org
Favicon
Automate Your C# Library Deployment: Publishing to NuGet and GitHub Packages with GitHub Actions
Favicon
My First NuGet Package: EmojiToText
Favicon
Publish C# Project to Nuget.org
Favicon
My Very First NuGet package
Favicon
Introducing VirtualStorageLibrary: A .NET Solution for In-Memory Tree Structures
Favicon
C# | Create Nuget Package using .NET Standard
Favicon
GitHub | Deploy .net core NuGet Packages in GitHub Packages Registry
Favicon
CSV Schema Validation
Favicon
Publishing Nuget in GitHub Packages
Favicon
.NET MAUI: Update NuGet Packages using Visual Studio Code
Favicon
How I Built a NuGet Package
Favicon
Lee's opinions on Umbraco + naming things
Favicon
Migrating the XM Cloud Introduction Repo to a new Nuget feed.
Favicon
How This NuGet Package Almost Cost Me My Job
Favicon
How to create and deploy a “Nuget Package” using Visual Studio
Favicon
How to change default Nuget packages folder on Windows
Favicon
How to Make a NuGet Package for C++ Development in Visual Studio
Favicon
Data Validation Nuget Package
Favicon
Create a NuGet-Package
Favicon
AspNetCore.VersionInfo 1.1.0 is out
Favicon
Deploying NuGet packages with Docker in GitHub actions
Favicon
Introducing TF WhatsUp, a Tool for Better Terraform Notes
Favicon
Creating a Nuget Package From a .Net 6 class library
Favicon
Elasticsearch.Net vs NEST

Featured ones: