4

in my assambly Version I want to set the first 3 digits and the fourth should be set thorugh Teamcity.

Example: I set 2.0.1.0 in my Assambly. Then my Teamcity should do: 2.0.1.90, 2.0.1.91...

At the moment I have: 2.0.1.%build.counter%

But what I want to have is, that 2.0.1 is set through my assambly version not through a hard number

Mohammad Nadeem
  • 9,134
  • 14
  • 56
  • 82
Rene Koch
  • 317
  • 3
  • 13
  • May be a duplicate of http://stackoverflow.com/questions/7258718/making-teamcity-version-match-net-assembly-version or http://stackoverflow.com/questions/1223245/assembly-versioning-with-teamcity – rmunn Oct 21 '15 at 09:20

1 Answers1

0

Which Teamcity version are you using? Teamcity 9.1 has a new build feature File Content Replacer which allows you to replace contents of a file using regex. However earlier versions of teamcity do not have this in built, so for them you'll have a write it on your own, May be a powershell script or MSBuild target.

Sample code for MSBuild target SetRevisionNumber

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.FileUpdate" />

  <Target Name="SetRevisionNumber" Condition="$(RevisionNumber) != ''">
    <Message Text="Setting Revision Number to $(RevisionNumber) in $(AssemblyVersionFile)" Importance="High" />

    <FileUpdate Files="$(AssemblyVersionFile)"
      Regex="\[assembly: AssemblyVersion\(.(\d+)\.(\d+)\.(\d+)\.(\d+)"
      ReplacementText="[assembly: AssemblyVersion(&quot;$1.$2.$3.$(RevisionNumber)" />

  </Target>
</Project>
Mohammad Nadeem
  • 9,134
  • 14
  • 56
  • 82