Need to know the version number before pushing to Octopus


Im not sure if this is problem that should be solved in Octopus or TFS. I was reading this thread because I had the same problem.

The solution here was to set the path to


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 ?


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!

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.


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: