Where should I put the nuspec file

thatsallfolks picture thatsallfolks · Apr 18, 2018 · Viewed 9.9k times · Source

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.

Answer

Andrei Dragotoniu picture Andrei Dragotoniu · Apr 18, 2018

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://docs.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.