Build number contains "???" when using variables

Hello,

we currently have a problem with TeamCity not correctly displaying the build numbers when using variables as part of our custom version number as they are always displayed as "???" on the overview and history pages:

teamcity_0005.PNG
teamcity_001.PNG

We want to use a specifically set major and minor version (this is managed by our internal development tools and configured in a xml file), the TeamCity variable %build.counter% for this build configuration as the build part and the current month and day for the revision part.
So our first build step is a custom PowerShell script to generate this version number and tell TeamCity to use it => ##teamcity[buildNumber '0.1.%build.counter%.0318'].
The next step is to update all AssemblyInfo.cs files for this solution with the generated version by passing it as a parameter to another PowerShell script:

teamcity_003.PNG

This works perfectly to build from the sources, create NuGet packages, push them to the internal servers and automatically deploy these packages.
For all these steps the version number is correctly set and used.
By looking at the details of a build and going to the "Parameters" tab one can see that the build.number is set correctly:

teamcity_002.PNG


I also created a test build configuration and tried some different build number formats like ##teamcity[buildNumber '1.0.{build.number}.0318'] which resulted in being displayed correctly on the overview and history page but not being replaced when passed to the PowerShell scripts:

teamcity_0006.PNG
Step 2/4: Set version number (Powershell)

[Step 2/4] PS Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[Step 2/4] in directory: L:\TeamCity\buildAgent\work\fac61b68a96fd8b2
[Step 2/4] Arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, L:\TeamCity\buildAgent\work\fac61b68a96fd8b2\teamcity\version_number_set.ps1, 1.0.{build.number}.0318]
...
Step 3/4: Build solution (Powershell) (27s)
[Step 3/4] Properties\AssemblyInfo.cs(14,12): error CS0647: Error emitting 'System.Reflection.AssemblyVersionAttribute' attribute -- 'The version specified '1.0.{build.number}.0318' is invalid'



So currently we can successfully use our custom build number but aren't able to easily cross reference this build number with a specific TeamCity build from the overview and history pages.
Is there something I'm missing?


Thanks in advance and best regards,
Chris
2 comments
Comment actions Permalink

You are passing build.number in the wrong format, I don't think TeamCity will evaluate the variable in {}. It should work if you change {build.number} to %build.number%

Arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, L:\TeamCity\buildAgent\work\fac61b68a96fd8b2\teamcity\version_number_set.ps1, 1.0.%build.number%.0318]

Cheers

Steve

0
Comment actions Permalink

It occurs only when you are trying to run PowerShell script from separate file but not by providing source code directly in TeamCity. Has anyone resolved it?

0

Please sign in to leave a comment.