What's the best way to create a TFSvNext Build Task to package and push to Octopus


Like most I’ve used OctoPack with a build property to make and push the packages to Octopus Deploy, I now use a custom build step for GitVersion and the Create Release and I want to great one to do the package and push step.

Can anyone suggest the best approach ? I’ve considered:

  1. Having another MSBuild Task which just runs the Octopack Tasks, but could find a way to do this, the out of the box step seems to want to build the solution again which is wasteful.

  2. Having a custom build task, I started with first by forking and cloning the new Custom Task for Creating a Release until I realised I couldn’t run OctoPack in the same way as Octo.exe.

  3. have a custom build task which runs some powershell to use NuGet to package and push in the same way Octopack does. Seems like the best way forward alothough my Powershell skills are pretty basic so this is going to be painful.

Any other suggestions ?



Just in case anyone is interested, I’ve made a start on a custom package by forking the current TFS Custom build and using as a template.

It needs final checking and some testing and I need to find out how best to identify the project.

Any feedback would be most welcome

Hi John,

Thanks for the email and great to see you’ve already made a start!

In fact, if you’re open to it, I’d love to incorporate the change you’ve already made to add support for Git repositories as well. If you’re happy with it, is there any chance you can submit a pull request to our repo?

I’ve planned to create a step to package and push to Octopus, however you’re right - it’s not as straightforward as the create release step.

I’d definitely agree that option 3 is the way to go, however OctoPack does a bit more work than Nuget, particularly when it detects the project is a web app (i.e. when it has a web.config).

Using octo.exe could be useful - it has an option to package all files in a folder. You’d just have to identify which folder has all the web resources. I’m hoping to create a step very soon to do just that.

I’m going to be spending a bit more time with the TFS/VSO integration very soon, but in the meantime I hope that helps!

Damian Brady

Hi John,

I realised after I wrote this that the Git change wasn’t yours. I’ve merged that PR from Jonathan Mezach now.

I’m looking forward to seeing what you come up with for the Nuget package and push to Octopus!

Damian Brady

Cheers Damian,

Yep, I saw the PR from Jonathan which was just what I needed so I started by fork from his :slight_smile:

It’s a shame Octopack isn’t available as a .exe out of the box as I agree it would be nice to take advantage of all of it’s goodness.

I’m hoping to get to a point where I can test something today but having to deploy into TFS to test seems like a pain so I feel like I’ll have to come up with some sort test harness to allow me to test it out.

I also need to take a look at the variables which are available, I’m currently thinking that I’ll need to :

Have a variable to accept a nuspec file location from the source your building.

Have a variable to give is a version (so I can pass in the GitVersion version mostly).

I’ve already pinched the credentials and url work you did for the Octopus Server so that should be ok.

Do you think I’ve missed anything ?

Hi John,

Thanks for the reply.

It doesn’t look like you’re missing anything. That strategy seems pretty sound. I’ve just tried to locate the list of variables, but they seem to have disappeared. I’ve alerted the team at Microsoft.

I’ll be attacking OctoPack soon to try to get a commandline version. I remember looking at it not long ago and discovering it was harder than I anticipated, so… we’ll see how it goes :slight_smile:


I’ve got something working by standing on the shoulder of various giants :

GitVersion – Head over to their repo to get the VSO custom task to allow setting of the version of your assemblies and packages.

NuGetPackagers, NuGetPublisher from here https://github.com/johnkattenhorn/vso-agent-tasks both built by an excellent chap called Lawerancegripper who’s work I’ve forked as it’s not yet merged and modified slightly to get around a VSO agent bug to do with using variables created during a build rather at the start of a build.

Seems to work, pushes into Octopus ok, final leg is to install your Custom Task for the release and I’m there :slight_smile:

I might pinch your release note work to put inside the NuGetPackage custom task since it’s really useful and can’t hurt to have the release notes in both places.

Hi Damien,

I really need to go to bed but now I’m using NuGet instead of OctoPack I’m getting issues.

I re-downloaded a uploaded NuGet which had been generated and it looks ok except the bin directory is missing. I current have no files section in the nuspec and I’m concerned about adding one since does’nt this switch off the other conventions ?

Can I add the bin files to the NuGet in some way ? Is there anything else I should be looking out for with the switch from Octopack to NuGet ?



Hi John,

Nice work!

Could it be the difference between a Website and a Web App? There’s a similar StackOverflow question I found. It looks like Websites don’t generate a bin folder at all.

We had similar issues with Nuget when we started using it for OctoPack. To get around it, we actually generate a nuspec file for a project then use that because just pointing at a csproj file didn’t give us what we wanted. OctoPack is open source, so you can have a look at what we’re doing here: https://github.com/OctopusDeploy/OctoPack.


Hi Damo,

This has been working great but like you said doing the work of Octopack using NuGet is a pain.

I’m still fiddling with the nuspec files to try to find a generic way as possible to package a MVC site, do you know anyone or anywhere I could go for some advice on nuspec, particularly what you can and can’t do with the files sections and filespec ?



PS. Upgrade to 3.1 as well - it’s been really good and wasn’t too much work to switch around the Azure config, I much prefer the 3.1 solution to the 3.0 one.

Hi John,

Probably the best place to go is the Nuget documentation itself. It’s fairly comprehensive.

We’re actually thinking of creating some sample .nuspec files for different types of projects - mainly because the whole ASP.NET vNext stuff will throw a big spanner in the works. The idea would be to make them as generic as possible. There may be a way to build that into a nuget pack build step as well - just choose the type of project you’re building and it’ll use a known Nuspec template.

That’s probably a little way down the track for us though, we have a few other priorities right now.

Thanks for the feedback on 3.1 - that’s really good to know. :slight_smile: