I'm experimenting with creating a NuGet package. I can create a package from a stand-alone class library project and it works fine. However, I'm seeing an error when I try to create a package from a class library project that references another class library project in the same solution.
I'm trying to create a NuGet package from a .NET Core 3.1 class library project, MyPackage
, which references another .NET Core 3.1 class library project, ReferencedClassLibrary
, in the same solution.
When I pack the MyPackage
project (via Visual Studio Solution Explorer > right click the project file > Pack) a *.nupkg file is created in the bin\debug folder. If I copy that *.nupkg file to the local NuGet package source I set up for testing, I can install the package into another solution.
However, during install of that NuGet package into another solution an error message is displayed:
NU1101: Unable to find package ReferencedClassLibrary. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, NuGet Personal Package Source, nuget.org
where "NuGet Personal Package Source" is the name of my local package source.
How do I include ReferencedClassLibrary
as part of NuGet package MyPackage
? Do I need to use NuGet.exe to pack the project with its dependencies or is there a way to do it via Visual Studio?