2
votes

I have a visual studio solution with the following structure

Project 1
   Reference Projec2
   Reference Projec3
Project 2
Project 3

All above are .NET 4 projects. I am trying to create a nuget package for Project 1, however using the default nuspec file, the package does not include the project2 and 3 assemblies in the net40 folder. Please note that I do not want to create separate packages for project2 and 3 as these assemblies are only ever used by Project 1.

To get around this, I am doing something like this

  <files>    
    <file src="bin\release\*.dll" target="lib\net40"                           
          exclude="**\Project1.dll"  />
  </files>

I was wondering if the above is the best solution?

Also for the Symbol package, it does not include .pdb files for Project 2 and 3?

I have also noticed that on the nuget website it says that

if you specify any files, the conventions are ignored and only the files listed in the .nuspec file are included in the package.

I don't see the above happening because when i use the element, i still get the Project1 assembly in the lib folder by convention, therefore I had to exclude it otherwise nuget throws exception that the file already exists.Any idea?

2

2 Answers

0
votes

If there is no reason for Project1, 2 and 3 to be separate (and you say that 2 and 3 are only ever used by 1), merge them into one project. You can separate concerns also by adding folders inside one project. For instance, for a typical MVVM-based WPF project I would have

MyProject
[ ]Properties -> contains AssemblyInfo.cs
[ ]Resources -> contains resources
[ ]Model -> contains Model classes
[ ]ViewModel -> contains ViewModel classes
[ ]View -> contains View classes
[ ]App -> contains App.xaml etc.

Etc. etc.

0
votes

You can add multiple assemblies (and PDBs) to your package, however, you will have to list them, as wildcards don't work (at least they didn't last time I tried).

Or you could automate the creation of the nuspec (and nupkg) file using a solution like this:

Add my utility, NuGetPack.exe and the standard NuGet.exe to your solution folder and the solution, then add a new class library project to your solution, reference the projects you want to package, then add a post build event to the new project and build.

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