Search code examples
nugetnuget-packageoctopus-deployoctopack

Specify Octopack nuget package file's target path


I found OctoPack to be incredibly straight forward when creating .nupkg nuget package files, however I I'd like the .nuspec file included (currently is placed in another folder such as obj/octopackage or something), and all the dlls should be placed inside a lib/net452 folder so that the general structure appears as such:

enter image description here

Currently everything that should be in the lib/net452 folder is simply placed in the root, along with _rels and package, and as mentioned the .nuspec file is missing.

Either the documentation is a little sparse or I've completely missed how to do this in my debugging mental haze. Anyone know how to specify to OctoPack where, specifically, to place the compiled output within the .nupkg file?


Solution

  • To create your NuGet package, you should be using nuget.exe, not OctoPack. I'll explain why in a minute.

    The .nuspec file serves as the "blueprint" for your NuGet package (.nupkg). So the short answer is to simply specify the location in your .nuspec file, using the target attribute of the <files> element. Details can be found on the NuGet site, but it would look something like this:

    <files>
      <file src="bin\$configuration$\*.dll" target="lib\net452\" />
    </files>
    

    There are a number of ways to call nuget.exe in a post-build step; many are explained on the NuGet site as well.

    OctoPack is not meant to create packages for nuget.org; it is designed specifically to create packages for Octopus Deploy. It creates packages one of two ways:

    1. If there is a web.config file present, OctoPack assumes that the project is a web project, and packages the output accordingly. It uses the project file to determine which items are marked as content, and which are not (although it will always grab web.config transformation files).
    2. Otherwise, OctoPack assumes that the project is an executable, or a component, and simply packs whatever it finds in the output folder (usually \Debug\bin or \Release\bin). This is the behavior that you're seeing.

    Since OctoPack uses nuget.exe under the hood, a .nuspec file will override both of the above cases. So while you could use OctoPack to create your NuGet package, it's more appropriate to use nuget.exe.