I have a Web project (W) which has a reference to a Class Library project (C):
W --> C
C references N1:
C --> N1
N1 is a custom NuGet Package that has two dependencies (both are also custom NuGet packages): N2 e N3, targeting version 2.1 or higher and 3.4 or higher, respectively.
N1 ---> N2 (>= 2.1)
`--> N3 (>= 3.4)
When I added the N1 package to C, N2 had a 2.2 version available, so NuGet got that one, instead of 2.1, as it was expected to do.
The problem starts here: when I build W, N2 is not copied to W's bin folder. I googled a bit, and found out that Visual Studio does not copy dependencies that are not "first class dependencies", that is, dependencies which are not used directly by C, to W's output folder. I can confirm that, because when I add the method below to any class in C, N2 gets copied.
private void ForceCopyOfN2()
{
var someObject = new N2.SomeClass();
}
Also, without the hack above, if I downgrade the version of N2 to the same version that is specified by the N1 package dependencies (i.e. from 2.2 to 2.1), N2 also gets copied.
So I am guessing this is an issue with NuGet. How NuGet is expected to work in this ocasion?
W --> C
C references N1:
C --> N1
N1 is a custom NuGet Package that has two dependencies (both are also custom NuGet packages): N2 e N3, targeting version 2.1 or higher and 3.4 or higher, respectively.
N1 ---> N2 (>= 2.1)
`--> N3 (>= 3.4)
When I added the N1 package to C, N2 had a 2.2 version available, so NuGet got that one, instead of 2.1, as it was expected to do.
The problem starts here: when I build W, N2 is not copied to W's bin folder. I googled a bit, and found out that Visual Studio does not copy dependencies that are not "first class dependencies", that is, dependencies which are not used directly by C, to W's output folder. I can confirm that, because when I add the method below to any class in C, N2 gets copied.
private void ForceCopyOfN2()
{
var someObject = new N2.SomeClass();
}
Also, without the hack above, if I downgrade the version of N2 to the same version that is specified by the N1 package dependencies (i.e. from 2.2 to 2.1), N2 also gets copied.
So I am guessing this is an issue with NuGet. How NuGet is expected to work in this ocasion?