octopus-deploynuspecoctopack

When does OctoPack create the nuspec file?


The Using OctoPack mentions

A .nuspec file describes the contents of your NuGet package. OctoPack automatically creates one if you haven't provided one, by guessing some of the settings from your project.

I've run msbuild with the /p:RunOctoPack=true flag set, and expect to see the .nuspec file in the project directory, but it isn't in the project directory or the output directory under /bin.

At what point is the .nuspec generated? Is it generated and saved or is it on the fly, if an overwrite .nuspec isn't provided?


Solution

  • It's typically best to create the NuSpec file in the root of your project that the OctoPack is installed in. To create the NuSpec file from the command line simply use nuget.exe:

    C:\temp\nuget.exe spec c:\path-to-project\solution\project\myproj.csproj
    

    This will create a myproj.csproj.nuspec file in the folder. You can edit the template however you please. Make sure to add the NuSpec within Visual Studio so that when TFS (or whatever CI you use) does a build, the NuSpec is copied and when the OctoPack is fired the NuSpec is already there.

    That said, the OctoPack will generate a NuSpec on the fly if it doesn't find it. You can view the source on GitHub (line 234 defines the method GetOrCreateNuSpecFile()):

    https://github.com/OctopusDeploy/OctoPack/blob/4b55bf0baa4d96cb7c2093cb234babc19a7d66f4/source/OctoPack.Tasks/CreateOctoPackPackage.cs#L234

    Like I said before, it's best to create the NuSpec file within your solution/project. For projects that aren't Web Apps in Visual Studio, there's a little work to be done in optimizing your packages for different projects (services, database scripts, MSIs, SSRS, etc. etc.)