Why is this NuGet dependency missing when compiling .NET Framework project depending on .NET Standard?
I'll repeat my comment above here, as it is considered valid as an answer.
The MSBuild
log, with its build output verbosity set to level detailed
, gives more insights in what happens.
Scenario 1 (A referencing B, B referencing C)
The build log shows that project A successfully resolved its System.Data.SqlClient
dependency from the \bin\debug
folder of project B and copies it locally.
(As project B is a .NET Framework class library, its NuGet dependencies do get copied to its bin
folder.)
Dependency "System.Data.SqlClient, Version=4.5.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Resolved file path is "C:\...\TestDependencyFlows.Library\bin\Debug\System.Data.SqlClient.dll".
Scenario 2 (A referencing B and C, B referencing C)
The build log mentions that project A tries to resolve its System.Data.SqlClient
dependency from the NET Standard
project C (and some wellknown folders), but not anymore from project B.
(Because project C is a NET Standard
project, it doesn't copy its NuGet
dependencies to its bin
folder.)
All these attempts fail with the message that the file doesn't exist at these locations.
Dependency "System.Data.SqlClient, Version=4.5.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Could not resolve this reference. Could not locate the assembly "System.Data.SqlClient, Version=4.5.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
For SearchPath "C:\...\TestDependencyFlows.Library.NetStandard\bin\Debug\netstandard2.0".
Considered "C:\...\TestDependencyFlows.Library.NetStandard\bin\Debug\netstandard2.0\System.Data.SqlClient.winmd", but it didn't exist.
Considered "C:\...\TTestDependencyFlows.Library.NetStandard\bin\Debug\netstandard2.0\System.Data.SqlClient.dll", but it didn't exist.
Considered "C:\...\TestDependencyFlows.Library.NetStandard\bin\Debug\netstandard2.0\System.Data.SqlClient.exe", but it didn't exist.
...
A solution could be to add the System.Data.SqlClient
NuGet package also to project A.