17

Say I have the following solution with multiple versions of the same code each targeting a different framework and I would like to generate a nuget package from it.

SharedLib.sln
  SharedLib.Net35.csproj
    packages.config
  SharedLib.Net40.csproj
    packages.config
  SharedLib.Phone.csproj
    packages.config
  SharedLib.SL4.csproj
    packages.config

The expected nupkg has the following structure

SharedLib.1.0.nupkg
  lib/net35/SharedLib.dll
  lib/net40/SharedLib.dll
  lib/sl4-wp/SharedLib.dll
  lib/sl4/SharedLib.dll

nuget.exe pack SharedLib.SL4.csproj will automatically determine that the target framework is SilverLight4 and place the binaries in lib/sl4

I know I can add a SharedLib.SL4.nuspec file with a <file> section to include binaries from the other projects but is there a way to make nuget automatically place the combined solution output into the proper structure (and also detect dependencies in packages.config from all projects?

Jesper Larsen-Ledet
  • 6,625
  • 3
  • 30
  • 42

1 Answers1

9

No, there's currently no way to do this other than to write a custom build script that puts the files in the right place and then runs NuGet pack on them, or to take the .nuspec approach you described.

This is a feature we'd like to have, but haven't thought of a good way to do it. However, your post just gave me an idea.

Today, you can point nuget pack at a .csproj file.

We could consider an approach that allowed you to point it at a .sln file and if the project names follow some convention, we'd package all the projects into a single package.

If you really want this feature, consider logging an issue in the NuGet issue tracker. http://nuget.codeplex.com/workitem/list/basic

Haacked
  • 58,045
  • 14
  • 90
  • 114
  • I might just do that though I'm not completely done figuring out what it is I want :) 1. it would be nice to point nuget at a solution and have it figure everything out 2. it would be nice if the different framework versions inside the resulting package could have different dependencies. e.g. the WP version might need an extra package that supplies types that are not part of WP core. I'll mark your answer as accepted for now and think a bit more on the issue. – Jesper Larsen-Ledet Oct 21 '11 at 18:33
  • 4
    Running nuget pack on a sln would be great. I want to package a set of related assemblies in a single package to make managing them more easy than seperate packages. They are not dependent on each other. – PenFold Dec 13 '11 at 19:02
  • 2
    The reason this is such a win is for build servers that are very convenient for building and publishing a package for a single proj, but become a nightmare when you need the above. To me, there's also some critical story missing that makes the whole feature redundant. Who *doesn't* need to package for each CLR? – Luke Puplett Apr 09 '13 at 19:46
  • Is this still not supported? – Philip Pittle Mar 12 '18 at 03:25