Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to tell NuGet to install package per project and not solution

I have a class library project which is reused across different solutions. I would like NuGet to add a toolkit reference to the class library project and store it in the project folder not in the solution folder.

Example:

I have

D:\Projects\MyClassLibrary

D:\Projects\Solution1

D:\Projects\Solution2

Using NuGet, I want to add a toolkit to the MyClassLibrary project.

Right now, if I have Solution1 open, NuGet is adding the toolkit to

D:\Projects\Solution1\packages

I would like to tell NuGet to install the toolkit in the MyClassLibrary\packages folder instead.

How to do this?

like image 230
WriteEatSleepRepeat Avatar asked Nov 01 '22 13:11

WriteEatSleepRepeat


1 Answers

You can change the default packages folder location since nuget 2.1:

<configuration>
  <config>
    <add key=" repositoryPath" value=" C:\myteam\teampackages" />
  </config>
  ... 
</configuration>

reference: Specify ‘packages’ Folder Location

-----------------UPDATE-------------------------

you have to enable nuget automatic package restore for the solution. When you do it nuget create a .nuget folder in the solution root.

Inside that folder there are the file NuGet.Config where you can put this configuration.

-----------------(last) UPDATE 2020-------------------------

nuget has changed since and this answer does not apply anymore

like image 52
giammin Avatar answered Nov 08 '22 07:11

giammin