Build NuGet Package automatically including referenced dependencies

Your point #3 (Add references to various .dll files/other projects <– this is the missing part) really contains two different issues: (1) add references to various dll files, and (2) add references to other projects in the same solution.

Number (2) here has gotten some added support as of NuGet 2.5. You can add an option to include references to other projects in the same solution when creating a NuGet package for a project:

nuget pack projectfile.csproj -IncludeReferencedProjects
  • If projectfile.csproj references any other projects in your solution that also is exposed as NuGet packages, these projects’ NuGet packages will be added as dependencies.
  • If it references projects in your solution that doesn’t expose themselves as NuGet packages, their dlls will be included in this NuGet package.

As for (1), if you find yourself often adding dlls to your projects that aren’t available as NuGet packages, you could just create your own (internal) NuGet packages with these files. If you then add these dlls as a NuGet package instead of the files directly, this NuGet package will be a dependency in your project’s NuGet package.

Leave a Comment