I have an MSBuild/C# project having a target trying to access `%build.counter% parameter supposed to be set by TeamCity.
<Target Name="TraceBuildParameters" BeforeTargets="BeforeBuild">
<Message Text="Build.Counter=$(build_counter)" />
</Target>
I can access it in TeamCity project build settings but none of this work in the script:
build.counter // msbuild error
build_counter // null
system_build_counter // null
teamcity_system_build_counter // null
teamcity_build_counter // null
Is it possible to access this parameter at all, is it exposed?
TeamCity will send any system
parameters to your MSBuild script (not configuration
parameters). If you explicitly want the %build.counter%
value, the easiest approach would be to set a system
parameter as follows:
system.BuildCounter = %build.counter%
Then you should be able to reference it as $(BuildCounter)
.
Alternatively, the build.number
is already sent to MSBuild as $(build_number)
. Depending on whether or not you've customised the build number on the Configuration -> General Settings
tab, this may save the need for the extra parameter.