Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget - packing a solution with multiple projects (targeting multiple frameworks)

Tags:

nuget

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?

like image 664
Jesper Larsen-Ledet Avatar asked Sep 27 '11 13:09

Jesper Larsen-Ledet


1 Answers

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

like image 97
Haacked Avatar answered Oct 21 '22 08:10

Haacked