Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I put the nuspec file

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.

like image 497
noStaleReads Avatar asked Apr 18 '18 13:04

noStaleReads


People also ask

How do I open a Nuspec file?

If you cannot open your NUSPEC file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a NUSPEC file directly in the browser: Just drag the file onto this browser window and drop it.

Where are NuGet credentials stored?

nuget.exe credential provider discovery Credential providers can be installed at the root of the CredentialProviders folder or within a subfolder.


2 Answers

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.

like image 197
Andrei Dragotoniu Avatar answered Oct 12 '22 03:10

Andrei Dragotoniu


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

like image 20
JackGrinningCat Avatar answered Oct 12 '22 05:10

JackGrinningCat