Getting Powershell scripts into Nuget Package


I’m trying to get the conventional powershell scripts supported by Octopus into the nuget package created when Octopack gets called.

At the moment the Octopack process is handled via a Teamcity Job, so an artefact of the website is produced ready to roll - great - what I’d like to know is what methods are available for getting a PostDeploy.ps1 script into this package.

So far, the only thing i’ve been able to do is to have the .ps1 script actually included within my Visual Studio web project, which I don’t want…I want that script to live at the root of my solution in a “Deploy” directory, or whatever, thus:

– FisherPrice.Web
---- something.aspx
– buildscript.whatever
---- PostDeploy.ps1

Am I doing it wrong, or missing something obvious? Any suggestions most welcome.

Thanks, Greg.

Hi Greg,

In this case you’ll need to modify your custom NuSpec file (for use with OctoPack) to reference the files you specifically want to include in your package. See this section for details:


Hi Paul,

Thanks for the reply - sorry, I should have mentioned that i’d been down that road already. If I include the <files> section in a custom nuspec, then in my octopacked output I get only the files specified in the<files> section (ie, only PostDeploy.ps1) - as mentioned in the docs you pointed to.

To clarify, i’m running this command to build the solution:

msbuild thing.sln /t:Rebuild /p:runoctopack=true /p:octopacknuspecfilename=myspec.nuspec

Clearly, I can’t specify every file in the web project in the custom nuspec - what can I do?

Hi Greg,

You can use wildcards in the source paths you specify, such as “bin*.dll”. We don’t have a way to automatically add to the existing files section at the moment.


Duh…of course.

Thanks Paul, that works.