Octopus Deploy with PublishedApplications

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:

<PropertyGroup>

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

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

    </PropertyGroup>


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…

PublishedApplications sweetness for TFS Build

I just learned that there exists a nuget package that allows you to build your non-web projects to a ‘_PublishedApplications’ directory just as your web projects are build to a ‘_PublishedWebsites’ directory.

Check it out: http://www.nuget.org/packages/PublishedApplications/

From there on it’s an easy ride to get your build to produce Octopus deploy packages. You can read about it here: http://help.octopusdeploy.com/discussions/problems/505-all-binaries-from-tfs-build-in-nuget-package

If you want to know all about setting up TFS build for Octopus deploy, check this great walkthrough: http://octopusdeploy.com/blog/automated-deployment-with-tfspreview-octopack-myget

Happy Coding!