Can TeamCity read a custom MSBuild property?

Here is the use case: To version the artifacts using the AssemblyInfoPatcher, I want to set the components of the version from an MSBuild property and get the revision from one of the predefined parameters.

Can TeamCity read an MSBuild property from what gets checked out so I can combine it with the predefined property during the build? Can someone point me to a tutorial?

Comment actions Permalink


TeamCity updates assembly version at the start of the build. When you pass the parameter from MSBuild it is resolved after AssemblyInfoPatcher updated version.
What is you use case, wouldn't it be an option to set version as TeamCity parameter?

Comment actions Permalink

I would rather have the developer specify the when checking in the code and have the source control system supply the last .revision. So my MSBuild task sets a TeamCity variable named Sedona.BuildNumber, but this varialbe is not available to AssemblyInfoPatcher:

  <!-- Sets Sedona.BuildNumber in TeamCity -->

  <Target Name="ReadAssemblyVersion">

    <ReadLinesFromFile File="Properties\AssemblyInfo.cs">

      <Output TaskParameter="Lines"




      <ReadAssemblyVersionPattern>\[assembly: AssemblyVersion\(.(\d+)\.(\d+)\.(\d+)</ReadAssemblyVersionPattern>


      <ReadAssemblyVersionOut>$([System.Text.RegularExpressions.Regex]::Match($(ReadAssemblyVersionIn), $(ReadAssemblyVersionPattern)))</ReadAssemblyVersionOut>

      <ReadAssemblyVersionValue>$(ReadAssemblyVersionOut.Remove(0, 28))</ReadAssemblyVersionValue>



  <Target Name="InitializeSedonaBuildNumber" DependsOnTargets="ReadAssemblyVersion">

    <Message Text="##teamcity[setParameter name='Sedona.BuildNumber' value='$(ReadAssemblyVersionValue)']" />


  <!-- Sets Sedona.BuildNumber in TeamCity -->

Comment actions Permalink

We have the same requirement.
Use Major.Minor.Patch from assembly file and add buildnumber using AssemblyInfoPatcher.

It would be mighty convenient if AssemblyInfoPatcher would make use of aterix placeholders like:


Comment actions Permalink

As I wrote in previous comment AssemblyInfo Patcher is started before build runners. So it does not know you changed the property.

The workaround is to add another build configuration and make snapshot dependency to current build configuration. You may specify build number as, where btID is the build configuration ID of the new configuration.


Please sign in to leave a comment.