Octopus Deploy Documentation

Include BuildEvent Files

Last updated

This page gives an example of extending OctoPack for when you have a PostBuild event in Visual Studio and want to include files that are not specifically part of your build, such as files that have been moved using Xcopy.

This example demonstrates the use of a PostBuild event in Visual Studio and the OctoPack option OctoPackEnforceAddingFiles.

I created a Post-Build Event using the Visual Studio Build Events feature. It uses Xcopy to move files from a path to my solution:

Post-build event

However, when I use OctoPack to package my solution on build my moved files are not included in the build:

Sample package without files

This is resolved by creating a NuSpec file, and creating a files tag to tell OctoPack to take my moved files, and put them inside a folder called bin\test in the package:

It is important to note here that for OctoPack to find and use a NuSpec file, it must be named the same as your project as seen above. For instance, in our example, the project is called OctoFX.TradingWebsite so our NuSpec file must be called OctoFx.TragingWebsite.nuspec.

To ensure I don't just get the files defined within the NeSpec file, I add /p:OctoPackEnforceAddingFiles=true, to tell OctoPack to also add the files it would normally add while building as well as those targeted by my files tag in the NuSpec file.

F:\Workspace\OctoFX\source>msbuild OctoFX.sln /t:Build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.0.0.7 /p:OctoPackEnforceAddingFiles=true

Now my test folder and files, as well as my build files, are included in the package.

Next

Welcome! We use cookies and data about how you use our website allow us to improve the website and your experience, and resolve technical errors. Our website uses cookies and shares some of your data with third party analytics companies for these purposes. We do not use these cookies for advertising.

If you decline, we will respect your privacy. A single cookie will be used in your browser to remember your preference.