Is it possible to change the location of packages for NuGet?

前端 未结 15 1964
误落风尘
误落风尘 2020-11-22 17:11

I have the following convention for most of my projects:

/src
    /Solution.sln
    /SolutionFolder
        /Project1
        /Project2
        /etc..
/lib
          


        
15条回答
  •  鱼传尺愫
    2020-11-22 17:22

    In order to change the path for projects using PackageReference instead of packages.config you need to use globalPackagesFolder

    From https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file

    globalPackagesFolder (projects using PackageReference only)

    The location of the default global packages folder. The default is %userprofile%.nuget\packages (Windows) or ~/.nuget/packages (Mac/Linux). A relative path can be used in project-specific nuget.config files. This setting is overridden by the NUGET_PACKAGES environment variable, which takes precedence.

    repositoryPath (packages.config only)

    The location in which to install NuGet packages instead of the default $(Solutiondir)/packages folder. A relative path can be used in project-specific nuget.config files. This setting is overridden by the NUGET_PACKAGES environment variable, which takes precedence.

    
        
        
    
    

    I put Nuget.config next to my solution file and it worked.

提交回复
热议问题