Octopus Deploy with PublishedApplications

By Dries Marckmann
April 9, 2013

Normally, when you install Octopack using nuget, the contents of the OutDir (msbuild variable) will be put in the nuget package it creates for you. But when running in TFS build this will give you trouble as mentioned in http://help.octopusdeploy.com/discussions/problems/505-all-binaries-from-tfs-build-in-nuget-package

A solution was mentioned to use the PublishedApplications nuget package to build each project to its own directory and I blogged as much yesterday…. But this is just a half-baked solution; yes, each project is build to its own directory, but octopack still takes the output of the tfs binaries folder for the packages. I found a way around this and I will describe it here.

I had to edit the source for octopack. I changed the dll to determine how a web project is recognized. Normally it does this by looking for a ‘web.config’ file, now you set the attribute TreadEveryProjectAsApplication to ‘true’ of the CreateOctoPackPackage task which will make octopack always use the content of the OutDir as input for the package. (It will ignore the content files in the project directory.)

I also removed the line where it excluded the files in the _PublishedWebsites folder, because I explicitly need these files.

Added this PropertyGroup to the octopack.targets file:


      <OctoPackDirectoryToPack Condition=‘$(ExeProjectOutputDir)’ != ”>$(ExeProjectOutputDir)</OctoPackDirectoryToPack>

      <OctoPackDirectoryToPack Condition=‘$(WebProjectOutputDir)’ != ”>$(WebProjectOutputDir)</OctoPackDirectoryToPack>


It will set the variable OctoPackDirectoryToPack to either ExeProjectOutputDir or WebProjectOutputDir. I then use that variable as input for the OutDir attribute of the CreateOctoPackPackage.

Download it here: http://bloggingabout.net/media/p/578418/download.aspx or check out the code at https://github.com/dmarckmann/OctoPack

Happy Coding!

PS. I later also created the property GetVersionFromAssemblyFileVersion (bool) if you want to get the version from the assemblyfileversion of the PrimaryOutputAssembly like we do. Download from github and build locally…

Comments: 0

Leave a Reply

Your email address will not be published. Required fields are marked *