I have two projects in solution. One is version 3.0.0.* and the other is 2.0.0.*. I build my solution on Team City using an MSBuild script. How can I inject the build number portion of the version string into the AssemblyVersion attribute leaving the major.minor.patch as defined at dev time.
To put it another way I want to manually control major.minor.patch (and the majors will differ across libs in the solution) but auto increment the build number.
TeamCity will automatically manage the AssemblyVersion attributes for you, but there are a few caveats:
With those caveats, here's how we've set it up:
Build number format
to%version%.{0}
%version%
as your major.minor.patch.AssemblyInfo patcher
. Make sure theAssembly 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.
Teamcity configuration build number is available to you in msbuild via $(BUILD_NUMBER). Leave your teambuild no to be the default {0}. I suggest you use this and edit the two assembly info files via a your own custom msbuild. You could keep a tokenised version of each file so that the version file contained 2.0.0.$(BUILD_NUMBER) in the version attribute and then use the extension pack detokenise to convert both (or any number of files for that matter). Still think you should have the same versioning on both projects though...