How to use TFS Build Number on Octopack

Hi,

I’m trying to setup the Nuget version to the TFS Build Number but everytime I get the following message:
Version string specified for package reference ‘$(BUILD_BUILDNUMBER)’ is invalid.
I already tried with $(Build.BuildNumber), $(Build.BuildName), $(Build.BuildId) and $(BUILD_BUILDNUMBER). Is like nothing gets transformed at that point.

I attached the image of the CI Process setup. I am passing the Octopack parameters at the MSBuildArguments field on the CI Process parameters.

Am I doing something incorrect?

Javi

Oops, wrong attached image, here is the right one.

Hi,

Thanks for reaching out! $(Build.BuildNumber) should be working I think. Have you checked what value gets assigned to that variable during the build? If for example it got an unvalid semver value like buiild1.0.0.0 that’ll explain the error you are getting.

It’ll all come down to what value is TFS assigning to that variableat build time. If you can print its value during your build to double check it, I’m sure that’ll lead to a good port.

Thanks,
Dalmiro

Hi Dalmiro,

The problem is, even on the exception log, it never indicates a transformed value, is like is not even happening:

Version string specified for package reference ‘$(BUILD_BUILDNUMBER)’ is invalid.
There was an error calling NuGet. Please see the output above for more details. Command line: ‘C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\packages\OctoPack.3.4.2\tools\NuGet.exe’ pack “C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\GA\CustomerCare\Web\Synergy\obj\octopacking\GA.CustomerCare.Web.Synergy.nuspec” -NoPackageAnalysis -BasePath “C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\GA\CustomerCare\Web\Synergy” -OutputDirectory “C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\GA\CustomerCare\Web\Synergy\obj\octopacked” -Version $(BUILD_BUILDNUMBER)
System.Exception: There was an error calling NuGet. Please see the output above for more details. Command line: ‘C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\packages\OctoPack.3.4.2\tools\NuGet.exe’ pack “C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\GA\CustomerCare\Web\Synergy\obj\octopacking\GA.CustomerCare.Web.Synergy.nuspec” -NoPackageAnalysis -BasePath “C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\GA\CustomerCare\Web\Synergy” -OutputDirectory “C:\Builds\Agent2\1.DEV-GA.Team\GA.DEV\Sources\GA\CustomerCare\Web\Synergy\obj\octopacked” -Version $(BUILD_BUILDNUMBER)
at OctoPack.Tasks.CreateOctoPackPackage.RunNuGet(String specFilePath, String octopacking, String octopacked, String projectDirectory) in z:\BuildAgent\work\20ba9f2e0d5e4022\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 588
at OctoPack.Tasks.CreateOctoPackPackage.Execute() in z:\BuildAgent\work\20ba9f2e0d5e4022\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 194

It may be worth to mention, I am using TFS 2012.

Yeah this is definitely a TFS 2012 thing. Try using $(TF_BUILD_BUILDNUMBER)

Already did, doesn’t work either. All the examples I have found are for TFS2103 and above.

I even tried to use a different one, like the revision number, it doesn’t work either, is like nothing is being transformed in the MSBuild parameters.

Have you tried quoting it like /p:OctopackPackageVersion="$(TF_BUILD_BUILDNUMBER)"

At this point I’m gessing just like you :). Got the idea from this link. Pre-TFS2015 documentation really sucks :frowning:

Tried this one too. I read almost all documentation I could found on Google.

I guess I have a couple of options here:

· Edit the Build Template

· Upgrade TFS (will happen soon)

· Keep passing the version manually (I don’t like this one)

But I was wondering if you have faced something like this before using TFS2012 specifcally.

Javi

Hi Javier,

Upgrading from that old TFS version is definitely recommended. I’m gonna ask around in the team to see if they can spot something we are missing here. Remember that the team is in Australia, so I’ll be getting back at you tomorrow at best.

Dalmiro

Thank you, I’ll wait for your response.

Javi

HI Javier,

I found an old thread in our forum that reminded me of something:

$(TF_BUILD_BUILDNUMBER) should return a value like CIBuild_20130613.6 which is not a valid semver value for a nuget package’s version. On that same thread a user proposed a way to modify the workflow (total pain, I know) to get just the version you need.

The comment of the user: http://help.octopusdeploy.com/discussions/problems/35393-cant-get-tfsbuild-with-octopackpackageversion-tf_build_buildnumber-to-work#comment_37230441

Hope that helps somehow

Hi Dalmiro, I can’t see the thread, it says is either Private or Deleted.

My bad. Thought it was public!

Here’s the relevant link: http://blog.nwcadence.com/inserting-team-build-number-into-the-octopack-run-version-for-a-nuget-package/

Thank you Dalmiro.