This project has moved and is read-only. For the latest updates, please go here.

Automatically including dependent projects

Apr 10, 2014 at 7:03 PM
I looked through the documentation but couldn't find what I'm looking for.

Let's say I have a solution with two C# projects: ClassLibrary1 and ClassLibrary2. ClassLibrary1 has a reference to ClassLibrary2.

When I set up ClassLibrary1 for automatic NuGet package creation, ClassLibrary2 doesn't get added as a dependency or reference in the package. So whenever I use types from ClassLibrary1 that reference types in ClassLibrary2, I'll get run-time exceptions because ClassLibrary2.dll can't be found.

I can go in and manually edit the .nupkg file afterwards to add ClassLibrary2.dll but that defeats the purpose of automatic package creation... (plus the package will get reset next time I build the solution and I'll have to manually edit the package all over again).
Apr 10, 2014 at 7:39 PM
Hey BrettHysuik, you just need to edit the BuildNewPackage-RanAutomatically.ps1 file to pass the -IncludeReferencedProjects switch to the NuGet executable's pack command; NuGet.exe doesn't use that setting by default.

So in that file just update:
$additionalPackOptions = ""
$additionalPackOptions = "-IncludeReferencedProjects"
Marked as answer by deadlydog on 4/10/2014 at 11:42 AM
Apr 10, 2014 at 7:42 PM
After searching around I came to the same conclusion. Thanks!
Jun 25, 2014 at 2:55 PM

I also searched for this information - maybe you can add it a little bit more prominent in the documentation (or add it as default).

Thanks for the project!

Aug 4, 2014 at 8:48 AM
I just recently learned about this script and thought it could be useful for our development and build environments.

I ran into the same issue being raised in this thread. But I couldn't find BuildNewPackage-RanAutomatically.ps1 mentioned here after I installed the New-Nuget package on my project. What am I missing?
Aug 4, 2014 at 5:20 PM
Modify the $packOptions variable in Config.ps1, e.g. $packOptions = "-IncludeReferencedProjects"
Marked as answer by deadlydog on 8/5/2014 at 9:03 AM
Aug 5, 2014 at 5:13 AM
Sep 10, 2014 at 1:04 PM
If ClassLibrary2 is also packaged as a NuGet package can you automatially add the correct dependancy?
  <dependency id="ClassLibrary2" version="1.0.0" />
Sep 10, 2014 at 11:34 PM
Yup. If you're project includes any other NuGet packages and they are referenced in the project's packages.config file, NuGet.exe should automatically include them as dependencies in your package without you having to change any settings. The -IncludeReferencedProjects switch mentioned above is necessary if your project references other projects in your solution, not other NuGet packages.