I'm building ClassLibrary2
which has a Project reference to ClassLibrary1
. ClassLibrary1
has a Nuget package Newtonsoft.Json
.
But when building ClassLibrary2
, the bin folder only contains ClassLibrary1.dll
and ClassLibrary2.dll
. How can I make it possible that Newtonsoft.Json.dll
is also copied into the bin folder of ClassLibrary2
?
If you were using an SDK-style project with PackageReference
-style NuGet references, then the package references would be transitive; ClassLibrary2
would automatically include the NuGet packages referenced by ClassLibrary1
.
Since you're using the older project format, with packages.config
NuGet references, those references are not transitive. Any NuGet reference you add to ClassLibrary1
must also be added to ClassLibrary2
.
Identify the project format | Microsoft Docs
For supported project types, there's a command-line tool you can install which will convert your projects to the new SDK style:
For new class libraries, it's usually simplest to start with the .NET Standard Class Library template, which uses the new project format by default.
ASP.NET (non-Core) projects don't support the new format. There may be others, but I can't find a definitive list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.