1

Description

TeamCity side: I defined a Configuration Parameter named major.minor.patch with an empty value. This can be accessed in TeamCity build steps as %major.minor.patch%

Visual Studio side:

In my .csproj file I added the code below to set major.minor.patch to the current version of my assembly:

<PropertyGroup Condition="'$(TEAMCITY_BUILD_PROPERTIES_FILE)' == ''">
  <TeamCityBuild>true</TeamCityBuild>
</PropertyGroup>

<!-- Other stuff... -->   

<Target Name="TeamCity" AfterTargets="Build" Condition="'$(TeamCityBuild)' == 'true'">
<GetAssemblyIdentity AssemblyFiles="obj\$(ConfigurationName)\$(TargetFileName)">
   <Output TaskParameter="Assemblies" ItemName="AssemblyItentity"/>
</GetAssemblyIdentity>
<Message Text="##teamcity[setParameter name='major.minor.patch' value='%(AssemblyIdentity.Version)'"/>

Problem

However, this code seems not working since the Parameter is still empty.

I also tried defining my parameter as an environment variable: env.maor.minor.patch, still no chance.

Question

  • How can I do this?
  • How to set a Configuration Parameter in TeamCity to my assembly version in my C# project?
A-Sharabiani
  • 17,750
  • 17
  • 113
  • 128

1 Answers1

1

Try setting the Importance of the Message to High

Message Text="##teamcity[setParameter name='major.minor.patch' value='%(AssemblyIdentity.Version)'" Importance="high" />
Mohammad Nadeem
  • 9,134
  • 14
  • 56
  • 82