I have several solutions that share certain common projects, such as one that contains all the necesary things to access my data model.

The actual problem is that trying to install packages with NuGet in one proyect with dependencies (ex. Iesi.Collections), creates a reference to the dll in the current solution directory and not in the proyect directory. Then, when I try to go to another of my solutions, the shared project fails to compile (because of the missing assembly).

I have searched all around for using NuGet in shared projects between solutions in an independent way.
So the question is... How can I manage obtain an independent behaviour and references between solutions in NuGet?
An alternative approach to this problem is modifying package reference path in .csproj file like by utilising $(SolutionDir) macro - this will point the reference to correct directory in both solutions:
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>
$(SolutionDir)packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll
</HintPath>
</Reference>
...
</ItemGroup>
One way to solve this issue is to add a .nuget\NuGet.config file to all solutions, and set the repositoryPath to a decicated local folder.
From this link, assuming you're using VS2015:
Create a .nuget folder in the root of the solution (on the file system) (if you're having trouble creating a .nuget folder using windows explorer, you can do so by entering .nuget. instead)
Inside that folder, create a file NuGet.config.
In Visual Studio 2015, right click on the solution and add a new solution directory called “.nuget”
Right click on that folder and select to add a new an existing file and select the NuGet.config file created in (2).
Add content like this inside the NuGet.config file:
<?xml version="1.0" encoding="utf-8"?> <configuration> <solution> <add key="disableSourceControlIntegration" value="true" /> </solution> <config> <add key="repositoryPath" value="..\..\..\..\NugetPackages" /> </config> </configuration>
Note that you'll have to fix existing references, for instance by removing and then adding all packages again.
I personally use an absolute path for the packages, since not all of my solutions are in the same folder hierarchy - if you're in a team you might want to discuss this first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With