Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a folder to a nuspec file

So I'm actually trying to package up a web site project (not web application so no csproj file) into a NuGet package ready for Octopus to consume but am running into one brick wall after another..

I looked into using OctoPack but it doesn't support web site projects only web application projects.

I am now trying to find a way of adding a folder (in my case a web site) into a Nuget package but Nuget doesn't allow this via the command line does it? It also requires a .csproj file!

I've also tried trying to create the NuGet spec files and pass it in a folder but not possible?

For the moment I may have to use the NuGet package explorer but I want to script this.

I've looked at this question but doesn't seem to handle my scenario Can I create a nuget package without a project file

So does anyone know how to best add a folder to a NuGet package via the command line!?

like image 921
Lee Englestone Avatar asked Jul 03 '14 10:07

Lee Englestone


People also ask

What is a Nuspec file?

A . nuspec file is an XML manifest that contains package metadata. This manifest is used both to build the package and to provide information to consumers. The manifest is always included in a package.

How do I edit a Nupkg file?

The Nuspec file is where all of your packages descriptions ( as name, version, description...), wil be. If necessary, you can edit the file by clicking on "Edit" button, to confirm your modifications you need to click on "Update" button.


1 Answers

I don't know OctoPack, but with nuget.exe, packaging is done in two steps:

  1. Either create a .nuspec manually, or generate one from a .csproj or existing assembly (see nuget spec in the docs).
  2. Call nuget pack with the .nuspec created in the previous step as a parameter.

Since you don't have a .csproj lying around, you're stuck creating the .nuspec manually (or with a GUI tool like NuGet Package Explorer).

You can read all about how to create a .nuspec file in the Nuspec Reference, specifically the section about Specifying Files to Include in the Package.

If you want to include a folder (recursively?) in the package, you need to add something like this to the XML:

<files>   <file src="bin\Release\**\*.*" target="content" />  </files> 

This will take all the files and (recursive) sub-folders of the bin\Release folder and put them in the content folder of the NuGet package.

I have no idea what format OctopusDeploy expects in the packages, but that's how you include a folder in the package.

EDIT: There seems to be some documentation on this in the OctoPack README.

like image 89
khellang Avatar answered Sep 22 '22 17:09

khellang