Need to know the version number before pushing to Octopus

Hi

Im not sure if this is problem that should be solved in Octopus or TFS. I was reading this thread http://help.octopusdeploy.com/discussions/questions/8286-package-not-found-when-publishing-to-octopus-server-after-vso-build because I had the same problem.

The solution here was to set the path to

$(build.artifactsStagingDirectory)\HelloWorld.0.1.$(Build.BuildNumber).nupkg

But this requires me to change this every time the version is incremented. Is there no way to express a pattern to push all .nupkg files in this step instead of knowing the exact path of the nupkg ?

Hi,

Thanks for reaching out! There’s no way to express a patter to push all nupkg files that way. But the approach we propose is a bit different:

  • The variable $(Build.BuildNumber) should contain the full build number, and not just a part of it (In your case you are leaving the 0.1 out of it and hardcoding it on the field). Instead, go to Build Definitions\[Your build def]\General and set the Build Number format to 0.1$(rev:.r)

  • Then use $(Build.BuildNumber) without any extra number before it for the Pack & Push steps. In the latter you’ll be using $(build.artifactsStagingDirectory)\HelloWorld.$(Build.BuildNumber).nupkg because now $(Build.BuildNumber) will hold the entire version.

Hope that helps!
Dalmiro

Forgot to mention: The advantage of doing this is that whenever you have to bump the version to lets say 0.2.*, you just have to do it in the Build Number Format field instead of doing it in every single field where you hardcoded the value.

Hi.

thanks for replying. I get your point. But we are aligning our assembly version with the build number. We generate a build number on 2 digtis and then replace them into a sharedAssemblyInfo file. So our build number in total will be like 1.2.12323.3 where 1.2.. is fixed from the source code and the ..12323.3 comes from the build. Im thinking if i could pull out this whole number and store it in a System variable and then use it later when pushing to octopus…

Hi - Yeah sounds like youre gona have to store it in a system variable in a step and then use that variable to create/push the package. This might help: https://roadtoalm.com/2016/08/11/set-output-variable-in-a-powershell-vsts-build-task/