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

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

I have the following convention for most of my projects:

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


        
15条回答
  •  -上瘾入骨i
    2020-11-22 17:36

    None of this answers was working for me (Nuget 2.8.6) because of missing some tips, will try to add them here as it might be useful for others.

    After reading the following sources:
    https://docs.nuget.org/consume/NuGet-Config-Settings
    https://github.com/NuGet/Home/issues/1346
    It appears that

    1. To make working Install-Package properly with different repositoryPath you need to use forward slashes, it's because they are using Uri object to parse location.
    2. Without $ on the begining it was still ignoring my settings.
    3. NuGet caches config file, so after modifications you need to reload solution/VS.
    4. I had also strange issue while using command of NuGet.exe to set this option, as it modified my global NuGet.exe under AppData\Roaming\NuGet and started to restore packages there (Since that file has higher priority, just guessing).

    E.g.

    
    
      
        
      
      
        
      
    
    

    You can also use NuGet command to ensure that syntax will be correct like this:

    NuGet.exe config -Set repositoryPath=$/../../../Common/packages -ConfigFile NuGet.Config
    

提交回复
热议问题