TeamCity will automatically manage the AssemblyVersion attributes for you, but there are a few caveats:
- It will totally overwrite the existing value.
- It will update all AssemblyVersions in the solution, so if you are tied to keeping different project versions in the same solution, this may not work for you.
With those caveats, here's how we've set it up:
- In the General Settings of your build configuration, change the
Build number format
to %version%.{0}
- In your Build Parameters define
%version%
as your major.minor.patch.
- In your Build Steps, scroll to the bottom of the screen and click Add Build Feature. Select
AssemblyInfo patcher
. Make sure the Assembly version format
is filled in as %build.number%
.
And that's it. TeamCity will update all your assembly infos to major.minor.patch.build as defined by the %version% and build counter, and then automatically revert those changes as the very last step of the build.