If I have a project (P1) that builds a nuget package, and I make it depend on a project (P2) that doesn't build a nuget package, the generated package will still reference P2 as a nuget package.
Steps to reproduce
- Create a solution with 2 C# projects (P1 and P2)
- Make P1 depend on P2.
Add the following line to P1.csproj (to make it build a nuget package)
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
- Build the solution
- Open the generated P1.nupkg in, e.g., NuGet Package Explorer
Note that the NuGet package depends on another NuGet package called P2. However, that package does not exist, and will never exist, as I have not told the P2 project to build a nuget package.
Question
How do I force P2.dll to be included in P1.nupkg's lib
folder? Ideally it will force it only for references that don't create a nuget package themselves.
Other questions
- Package .NET Standard library as Nuget package and include all project dependencies / references is related, but assumes the use of
nuget pack
. I am usingdotnet build
or Visual Studio to build the nuget package, so doesn't apply. - This GitHub query is pretty much the same as my issue.