2

Context

In our repo, we have a file called version.txt that contains the major and minor version number: 0.7.

I added a TeamCity build step with a powershell script that sets this parameter into a config parameter, based on this answer:

$version = Get-Content version.txt
Write-Host "##teamcity[setParameter name='UserMajorDotMinor' value='$version']"

The UserMajorDotMinor parameter defaults to 0.6 on TeamCity.

I have a config parameter called %UserVersionNumber% that is used to set the actual version number, which is defined as

%UserMajorDotMinor%.0.%system.build.number%

The Problem

While prints 0.7 in the TeamCity build log, but it doesn't seem to properly set the UserVersionNumber, because the number that the assembly patcher writes into the dll is still 0.6.0.xxxxx.

What do I have to change so TeamCity will actually write the correct version number into the dlls?

Community
  • 1
  • 1
Wilbert
  • 7,251
  • 6
  • 51
  • 91
  • 1
    The Assembly patcher will run before any build step, therefore, changes made to parameters within a step won´t reflect in the Assembly Info Patcher. – Mecaveli Nov 26 '15 at 15:22
  • Looks like a duplicate of [TeamCity - AssemblyInfoPatcher not working, error is logged](http://stackoverflow.com/questions/33938529). – Bass Nov 27 '15 at 11:06
  • Not really a duplicate, even if the solutions are similar. – Wilbert Nov 27 '15 at 12:24

1 Answers1

2

The Assembly Info Patcher build feature will run before any build step, therefore, changes made to parameters within a step won´t affect the Assembly Info Patcher

If you really need to use the Major.Minor Info from the version.txt file then i would setup a seperate build configuration that reads the file and provides the content as build parameter %UserMajorDotMinor%. Basicly what you already did.

Then you can add the newly created config as dependency to the actual build and set the %Version% Parameter to %dep.[buildconfigname].UserMajorDotMinor%.0.%system.build.number%

As a Alternative, use a Script to patch your AssemblyInfo.cs files as seperate build step instead of the Assembly Info Pather Feature.

Mecaveli
  • 1,507
  • 10
  • 16