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.
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.
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
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.
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.