Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Nuget with more than one solution

Tags:

nuget

I have a number of solutions which share the same projects in different folders, for example,

Common folder
 - common 1
 - common 2
Contracts folder
 - contracts for project A
 - contracts for Project B
Application 1 folder (in this folder I have my solution file)
 - Solution A
 - nuget creates packages folder there
Application 2 folder
 - Solution B
 - nuget creates packages folder there
packages folder( I need this folder at top level, so all projects can reference it)

With this structure Nuget creates two packages folder inside of Application 1 and Application 2

But all of this projects and solutions related to each other, so logically it's better to have only one packages folder.

Is it possible to set in nuget only one folder and use that folder for all solutions?

Or should I structure my solutions and projects another way?

like image 965
Yaplex Avatar asked Dec 23 '11 20:12

Yaplex


1 Answers

You can do this by adding nuget.config files to each solution with following contents

<settings>
<repositoryPath>..\Packages</repositoryPath>
</settings>

Make sure that they all point to the same folder.

When you make this file, you have to restart Visual Studio to make it use this setting ( or at least close and open the solution).

But more practical would be to create just one nuget.config that all solutions make use of. Just make sure it resides on a folder higher then any solution file you wish to include. When restoring, the nuget manager searches for this file, starting from next to the solution file and if not found, start looking higher up the folder structure.

like image 157
Schwarzie2478 Avatar answered Jan 08 '23 07:01

Schwarzie2478