16

I want to change NuGet package folder, but it does not change it. What I do is creating file nuget.config:

<configuration>
    <config>
        <add key="repositoryPath" value="C:\projects\" />
    </config>
</configuration>

I added this file in the solution folder (in same folder where is .sln file) or in the project folder and after that restart VS, but nothing happen. I am using Visual Studio 2017 Community.

gdfgdfg
  • 3,181
  • 7
  • 37
  • 83
  • I noticed that you are creating Xamarin.Forms project with Visual Studio Community 2017, the reference should be PackageReference, for this sort of project, you should use `D:\Test\packages` in the the .csproj file. Hope this help you. You can check my updated answer for more detailed info. – Leo Liu Dec 19 '17 at 04:21
  • Any update for this issue? Have you resolved this issue? If not, please let me know the latest staus about this issue. I will keep follow. – Leo Liu Dec 19 '17 at 17:56

2 Answers2

27

Change NuGet package location folder

Depending on what sort of project you are using this setting may or may not be successfully to change NuGet packager folder.

If you are using a .NET Framework project that has a packages.config file then this setting will change the nuget package folder to C:\projects\.

But if you are using a project.json file, then this setting will not successful. Because project.json project doesn't support repositoryPath config.

To change the nuget packager folder, you can you can set "NUGET_PACKAGES" environment variable. Just Set "NUGET_PACKAGES" = "c:\teampackages". Or you can place a NuGet.Config file next to the solution with the following content:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <config>
      <add key="globalPackagesFolder" value=".\packages" />
    </config>
</configuration>

For the detail info, you can refer to this thread:

Dotnet restore does not honour nuget.config 'repositoryPath'.

Update:

I noticed that you are creating Xamarin.Forms project with Visual Studio Community 2017, the reference should be PackageReference, for this sort of project, you should use add below code to the .csproj file:

<PropertyGroup>
  <RestorePackagesPath>D:\Test\packages</RestorePackagesPath>
</PropertyGroup>

Then restart Visual Studio, VS/NuGet will restore nuget packages to the D:\Test\packages, it works fine on my side, you can check my test sample:

enter image description here

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
-4

In Tools/Nuget Package Manager/Package Manager Settings Options

Raphael
  • 11
  • 1
  • 5