I'm using visual studio 2019 community version and the package manager console. I am using .net core 2.2 and Package References is enabled. I want to be able to create one single nuget pack coreproj1 which will also include the dlls for Coreproj2 and coreProj3, without having to pack CoreProj2 and CoreProj3 as there are many projects and packing them all is not feasible. I've looked online and cannot find a clear solution as not many of them are using package reference
CoreProj1 references CoreProj2 and CoreProj3
CoreProj2 and CoreProj3 do not reference anything
I'm currently using
dotnet pack "full project path" --output "outputPath"
When i try to install the package i get the following error (i get the same error for CoreProj3)
Error NU1101 Unable to find package CoreProj2. No packages exist with this id in source(s): LocalPackages, Microsoft Visual Studio Offline Packages, nuget.org, TestNuget source\repos\TestNuget\TestNuget\TestNuget.csproj 1
Including referenced projects assemblies using the MSBuild pack targets (dotnet pack
is effectively just an alias for dotnet msbuld -t:pack
) is not supported. nuget.exe pack
has a IncludeReferencedProjects
argument that does what you wish, but does not work correctly for projects using PackageReference
or SDK-style projects (which are always PackageReference
).
One possible workaround is to have a build script that first build all your projects, then copies all your assemblies into a nuget package layout, and use nuget.exe pack
to pack that directory layout.
Another workaround is to have a nuspec
with a bunch of <file src="..." target="lib\<tfm>\">
elements that tells NuGet to pack all the assemblies from their compiled locations.
Another workaround is to use MSBuild extensibility to tell NuGet's MSBuils targets about the assemblies you want packed after build, but before pack. There are some comments in the thread linked above giving examples how it might be done.