4

I have a build that has a custom build step that reads a text file out of the repository and writes to the build.version configuration parameter. I'm trying to use that value in an AssemblyInfo patcher like this: %build.version%.%system.build.number%.

The build keeps failing with an error similar to:

error CS0647: Error emitting 'System.Reflection.AssemblyVersionAttribute' attribute -- 'The version specified '.26' is invalid'

After the build runs, I can see in the Parameters tab that build.version is set to the correct value.

Am I doing something wrong here or is there a better way to accomplish this?

UPDATE: I see in the build log now that the AssemblyInfo patcher is running prior to my first build step that sets the value. Is there any way to delay it until after the first build step?

Nathan Roe
  • 844
  • 1
  • 8
  • 22

3 Answers3

2

There doesn't appear to be a workaround for this inside TeamCity. It always runs the AssemblyInfo patcher prior to the first build step.

I ended up solving this problem using Rake and Albacore to script my build. This allowed me to setup my versioning myself and also had the nice side effect of allowing me to test my build before running it in TeamCity.

Nathan Roe
  • 844
  • 1
  • 8
  • 22
0

From TeamCity documentation:

Configuration parameters (no prefix) are not passed into the build and are only meant to share settings within a build configuration. They are the primary means for customizing a build configuration which is based on a template or uses a meta-runner .

Instead, you should use system properties (defined on Build Parameters tab). You can even feed a config parameter as a value to a system property.

Andriy Volkov
  • 18,653
  • 9
  • 68
  • 83
  • 1
    I tried changing it to a system parameter (system.build.version) and I get the same error. I'm initially setting up the parameter with an empty value and then changing it in the first step of my build. – Nathan Roe Jan 15 '15 at 21:17
  • I also tried initializing the value to 0.0. That fixed the build but the assembly is getting the version number 0.0.build_number. – Nathan Roe Jan 15 '15 at 21:21
0

Another option is to generate the dynamic build number in a separate parent build and then consume that build number via a snapshot dependency. Set the child's build number to %dep.PARENT_BUILD_ID.build.number%. This way the build number is already defined when AssemblyInfo Patcher runs. See https://stackoverflow.com/a/35095917/1130636 for more details

Community
  • 1
  • 1
borigas
  • 495
  • 5
  • 11