0

I have 2 solutions:

  • Solution1
    • Project1.1: references nuget package NU1
  • Solution2
    • Project2.1: references Solution1 / Project1.1

When I build Solution2 it fails because nuget pulls the NU1 package to the packages of Solution2, and when Project1.1 is built as a dependency, the package NU1 is missing.

Prior questions and answers have convinced me to reference projects better that .dlls -- however, I am afraid I have not yet understood how to follow this guideline when working with nuget.

Thank you in advance for your comments!

3 Answers3

0

You should reference project when they are in the same solution. In every other case you should reference nuget.

This may require private nuget feed.

Why this way?

  1. solutions doesn't have anything in common - next developer won't understand this hidden reference
  2. if you use them only together maybe they should be in solution
Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116
  • I am agree with "Piotr Stapp" .. NuGet is a package management ( open source) system for .NET and to be honest its goal to make process of incorporating other dll especially third party dll into your solutions simple. – Rajeev Bera Dec 21 '15 at 10:32
0

Eventually, I managed like this:

  • created a packages directory parallel to solution directories
  • each solution get a nuget.config file with

=> all solutions use same packages :)

0

The issue is the Solution1 resolves it's references by looking into Solution1\package folder and this won't happen when building Solution2

Open your csproj file to find

<ItemGroup>
    <Reference>      
       <HintPath>..\..\packages\SomeReference\lib\net45\Reference.dll</HintPath>    

replace the relative location ..\..\ with $(SolutionDir) as

<HintPath>$(SolutionDir)\packages\SomeReference\lib\net45\Reference.dll</HintPath>   

Since the $(SolutionDir) will be the path to the solution folder it will resolve all the reference issues for the future.

Vinod Srivastav
  • 3,644
  • 1
  • 27
  • 40