How to pass buildnumber to OctoPackPackageVersion on build?

I asked a simliar question months ago at http://help.octopusdeploy.com/discussions/problems/35393-cant-get-tfsbuild-with-octopackpackageversion-tf_build_buildnumber-to-work , but since then I’ve had to move to TFS online and things don’t work the same over there. Now I’ve tried:
/p:OctoPackPackageVersion=$(TF_BUILD_BUILDNUMBER)
/p:OctoPackPackageVersion=$(BUILDNUMBER)
/p:OctoPackPackageVersion=BUILDNUMBER
/p:OctoPackPackageVersion=%build.number%

but i keep getting the same error on build, which is :
MSBUILD : OctoPack error OCTONUGET: ‘%build.number%’ is not a valid version string

How should pass the buildnumber to OctoPackPackageVersion through the msbuild arguments field?

Hi Phil,

Thanks for getting in touch!

I don’t blame you for having trouble finding the correct variable - there’s been so much motion over the last while that finding the correct resource is very difficult.

The variable you’re looking for is $(BUILD_BUILDNUMBER). You can find the correct list of built-in variables by going to https://msdn.microsoft.com/Library/vs/alm/Build/scripts/variables.

There’s actually a link to this page from the top of the Variables tab in your Build definition in VSTS (formerly Visual Visual Studio Online).

Let me know how you go!
Damo

Just used this variable, and got the same error:
MSBUILD : OctoPack error OCTONUGET: ‘$(BUILD_BUILDNUMBER)’ is not a valid version string.

Basically, this is what i’m passing into the msbuild arguments section:
/p:RunOctoPack=true /p:OctoPackPublishPackageToHttp=MyUrl /p:OctoPackPublishApiKey=MyKey /p:OctoPackPackageVersion=$(BUILD_BUILDNUMBER)

and that doesn’t seem to be working. Should i be writing it out differently?

Hi Phil,

Oh I’m sorry, I didn’t read the page properly! That version of the variable was the environment variable you can use if you’re using it in a script.

Can you try $(Build.BuildNumber) and let me know how that goes?

Thanks,
Damo

That did it, thank you!