9

I've searched the entire stackoverflow community but I couldn't find an answer for this...

I have a .nuspec file and I have no idea where I have to put it. Some topics say that I have to put it in the project directory and include in version control. Others say that its just keep the file in the same directory that the .nupkg file... but it doesn't worked to me. Any idea?

Thanks in advance.

no-stale-reads
  • 177
  • 1
  • 1
  • 11

2 Answers2

8

A NUSpec file contains package metadata and is used to create a package.

A package is created from your project, which is why it would make sense to place the NUSpec file in the project folder.

It makes sense because it can then be committed to your source control as part of that project and this keeps everything in one place, it makes it easier to create the package automatically using your CI / CD pipeline.

You could, of course, do other things like create a NUSpec folder on the same level with your project folder and you could put your file there. Nuget.exe accepts a path to your NUSpec file so the actual location is irrelevant.

However, always consider your source control and how you manage / create this package, as long as you can do that easily, then place it wherever it makes sense to you.

You mentioned NPE, that doesn't really matter as behind the scenes it will more than likely call nuget.exe anyway. If you want to learn how to use it, have a look here : https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package.

They also recommend, as a convention, to have the nuspec file in the same location as the proj file.

Andrei Dragotoniu
  • 6,155
  • 3
  • 18
  • 32
1

As i understand from on of you comments you construct the package with the NPE. As far as I remember the NPE was a ClickOnce application which opens up packages and you can put or even create packages there.

When the question is: Where do i put the nuspec within the package? the answer is: In the root folder of the package:

Otherwise the answer is already answered by the other answer.

Infos:

  • nuget packages are zip files
  • To get an idea where the nuspec resides in other packages just open one with NPE or 7zip
  • I had a look into the newtonsoft.json package
  • Unzipped it and it's obviously in the root folder of the package

enter image description here

JackGrinningCat
  • 480
  • 4
  • 9