Reputation: 332
I'd begin with saying that I never had any experience with managing NuGet packages, even the simplest ones. However, I'm planning to use it in my next project, which design could rely on the answers to my question.
For a better understanding of the problem, let's assume we have the following projects, all under one solution:
Both Foo and Bar depend on Core, but not on each other.
As such, I'd like to create one nuget package for the Foo + Core combination, and one for the Bar + Core combination, without separating them to different solutions.
Is this scenario possible?
Upvotes: 2
Views: 2221
Reputation: 444
Yes, your scenario is possible. NuGet package creation doesn't depend on the solution the project belongs to. You can either define your own nuspec file to pack a package or use a csproj file to do so. Look at: https://learn.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference
Note: NuGet primarily packes .dll files into a package. Even if you use .csproj files, it looks at the and picks up the .dll from that location. You can choose to store the Sourcecode using the NuSpec file though.
For a NuSpec file:
For a .csproj file(I think this is what you should use):
nuget pack <nuspecPath | projectPath> [options]
command
IncludeReferencedProjects
as an option, and projectpath
for Foo and Bar individually. This would create two separate NuGet packages
which fulfill your need.Upvotes: 2