0

I'm trying to create a NuGet package for an MSBuild Extension that should contain a template .nuspec file.

However when I specify a .nuspec file to be content of my package, I'm not able to install it in a .nuget folder of the target project.

As you can see in the screenshot, it will create a .nuget\NuSpecTemplate.nuspec folder in which the embedded .nuspec file will be created. I've named the template .spec, since NuGet will ignore the source file if it is named .nuspec.

Is this by design, or is it a bug in NuGet?

Screenshot

Eivind Gussiås Løkseth
  • 1,862
  • 2
  • 21
  • 35
  • If I change the target file ending to .spec instead of renaming it to .nuspec, it will be placed directly in the .nuget folder of the target project, but then I'll have to instruct the user of the package to change file extension from .spec to .nuspec. – Eivind Gussiås Løkseth Mar 18 '15 at 12:39
  • If you use .nuspec is the file in the generated .nupkg? Looking at the NuGet source code it will always exclude .nuspec file when creating the NuGet package. If that is the case then you will probably have to resort to adding the file with a PowerShell script. – Matt Ward Mar 18 '15 at 13:21
  • What's the name of your NuGet pkg I'll take a look at it. Is the code open source? – Sayed Ibrahim Hashimi Mar 19 '15 at 02:07
  • The project isn't open source, but I've reproduced it in a new project here: https://github.com/eloekset/NuspecFileBundledInNuGetPackageDemo If you build this project and watch the build log, you can see that the file named TargetProjectNuSpecFile.nuspec is ignored from the content. DemoPackage.nuspec is the file that defines the NuGet package that's being built. – Eivind Gussiås Løkseth Mar 19 '15 at 21:27
  • I think @MattWard answers the question. NuGet ignoring .nuspec files as content in NuGet packages is by design. – Eivind Gussiås Løkseth Mar 20 '15 at 07:54
  • It would be interesting to know why this design decision has been made. Is it some kind of security consideration? Maybe Matt can tell exactly where in the NuGet code this is found? – Eivind Gussiås Løkseth Mar 20 '15 at 08:16

0 Answers0