Create nuget package with multiple DLLs

You'll run NuGet on a single project (or nuspec file), but it supports pointers to other projects via the file element. This element uses the names of your project's References, so you avoid having to a) find the location of other project files, and b) copy files to a particular place as a post-build step.

Supposing you have a nuspec file for MyLibrary.Core.csproj, and it references MyLibrary.Extensions and MyLibrary.Tests such that they end up in the bin directory after a build:

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    ...
  </metadata>
  <files>
    <file src="bin\Release\MyLibrary.Extensions.dll" target="lib\net40" />
    <file src="bin\Release\MyLibrary.Tests.dll" target="lib\net40" />
  </files>
</package>

With this setup, all of your references should end up in the appropriate place in the NuGet package. You still have the hard-coded 'Release' in there, but I'd wager most probably don't distribute NuGet packages of their debug builds anyway.


Did you generate a blank nuspec file with:

nuget spec

If you use that file and then put your dlls in a folder under it named lib, it will package them up.

I had a little trouble with trying to generate a nuspec file from a project or dll. Also, if you manually reference any files in the nuspec file, the conventions are not used. This is probably the problem with nuspecs generated from dlls or projects.

Also, if you are trying to run this from a build script that executes in a different folder, you can tell nuget the location of your .\lib folder via the -BasePath command line:

build\nuget.exe pack nuget\Company.Project.nuspec -BasePath nuget\

Have you tried NuGet Package Explorer? Might be the easiest way:

http://nuget.codeplex.com/releases/view/59864


It seems your problem is the same as this question: Why doesn't nuget include the referenced project when packing?. If so, you can use the -includereferencedprojects option (See http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command).


I recently published a solution for this...

My solution enables automatic creation of NuGet packages when you build the solution where each package can contain multiple assemblies, references to both external NuGets and NuGets created during the same build and even include the source code for debugging.

In your case, all you will need to do is add a new class library project to your solution, reference the projects you want to package, then add a post build event.

You can find an article with a walk-through guide here and the source code here.