简体   繁体   中英

ProjectReference which consumes a Nuget package isn't included when building

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:

hvanbakel/CsprojToVs2017: Tooling for converting pre 2017 project to the new Visual Studio 2017 format

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM