Nuspec file generated by nuget can't be reused

May 9, 2011 at 6:43 PM

I created a project, then ran

nuget pack ./myproj.csproj

Which worked successfully.

However if I open MyProj1.0.nupkg and take the nuspec file out, running

nuget pack ./myproj.nuspec

Results in an entirely different package that just loads every single file of my project into the package.

This doesn't seem right.

May 9, 2011 at 7:36 PM

The nuspec file in the package is not expected to be the same as the one outside. The one outside can point to files all over your drive, while the one inside only knows about files that are in the zip.

Stepping back a bit, what are you trying to achieve?

May 9, 2011 at 8:02 PM
Edited May 9, 2011 at 8:02 PM

This is the way I would envision (and I feel the majority of all developers) establishing a brand new nuget package.

Create a project, at this point have nuget generate the base package off the project file, use the package explorer to add content and powershell files, then copy the nuspec file out of the package, put the nuspec file in the project directly, configure the build settings to generate packages using the nuspec file.

This flow is currently broken that the nuspec file created by nuget doesn't have the right information to do this, which is even further confusing since I thought the nuspec file was supposed to maintain ALL of this. But clearly those rels or whatever files can do that work too.

May 9, 2011 at 8:08 PM

The 'standard' workflow right now is more:

  • Run 'nuget spec' on your project to generate a starting nuspec file
  • Make any changes you need
  • Build the package

You should never have to extract the nuspec from the built package.

The downside of this workflow is that you have to hand edit the nuspec file. Where I could see it being improved is that Package Explorer should be able to help with authoring the nuspec file, and maybe it doesn't do that today.

May 9, 2011 at 8:24 PM
Edited May 9, 2011 at 8:24 PM

Why would nuget create a spec file & package different than the one you would hand create?

May 9, 2011 at 8:28 PM

When you run 'nuget spec' to create a nuspec file, it creates the same type of files you would create by hand. The one you see inside the zip is a different beast, and you should basically pretend that it's not there. It is not meant to be extracted individually from the package.