<PackageReference>)
public class Class1
{
public void A() => Newtonsoft.Json.JsonConvert.SerializeObject(null); // Use Newtonsoft.Json
}
Execute the following command line
msbuild /bl
=> Build failed
In ClassLibrary2 add a NuGet reference to a NuGet package that doesn't depend on Newtonsoft.Json, such as NUnit (<PackageReference>)
Execute the following command line
msbuild /bl
=> Build succeed
I think the first build should succeed, or the second one should fail.
It fails.
msbuild /version output:
15.6.85.37198
OS info:
Windows 10 1607
If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
Visual Studio 15.6.7 and command line (msbuild)
This is a NuGet behavior. Older versions of NuGet didn't treat dependencies as transitive in this way, so NuGet (currently) requires you to explicitly opt into the new behavior from your ClassLibrary2 with
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
https://github.com/NuGet/Home/issues/4581 would also help for this case.
Duplicate of NuGet/Home#4488
Most helpful comment
This is a NuGet behavior. Older versions of NuGet didn't treat dependencies as transitive in this way, so NuGet (currently) requires you to explicitly opt into the new behavior from your ClassLibrary2 with
https://github.com/NuGet/Home/issues/4581 would also help for this case.