How to instruct your msbuild script to set the correct “AssemblyVersion” of your libraries using “AssemblyInfo.cs” when building in a Bamboo server.In Puzzlepart it is vital to have the current build number and the current revision number in the assembly version of products.
Solution :
Assembly version syntax : <major version>.<minor version>.<build number>.<revision>
More info can be found here about the syntax.
Step 1 : First you need to make sure the corresponding Build-Specific Variable are passed into the build script.
How ?
In Bamboo build configuration under the “Builder” tab you have “Options” where you can pass msbuild command line switches.Step 2 : Accessing those variables from the msbuild script
example : /p:BuildKey=${bamboo.buildKey} /p:BuildPlanName=${bamboo.buildPlanName} /p:BuildNumber=${bamboo.buildNumber} /p:Revision=${bamboo.custom.svn.revision.number}
<PropertyGroup>Step 3 : Create the Assembly version using those properties
<MajorVersion Condition="'$(MajorVersion)' == ''">1</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">0</MinorVersion>
<BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
<Revision Condition="'$(Revision)' == ''">0</Revision>
<BuildPlanName Condition="'$(BuildPlanName)' == ''">LocalBuild</BuildPlanName>
<BuildKey Condition="'$(BuildKey)' == ''">NOKEY</BuildKey>
</PropertyGroup>
<PropertyGroup>Step 4 : Use the assembly version in “AssemblyInfo” task
<ComputedAssemblyName>$(MajorVersion).$(MinorVersion).$(BuildNumber).$(Revision)</ComputedAssemblyName>
</PropertyGroup>
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(ApplicationName)\Properties\AssemblyInfo.cs"
AssemblyTitle="ApplicationName"
AssemblyDescription="Description"
AssemblyCompany=""
AssemblyProduct="$(ApplicationName)"
AssemblyCopyright="Copyright © "
ComVisible="false"
CLSCompliant="false"
Guid="248D49F7-BC5D-4413-8E4A-98B4654B1594"
AssemblyVersion="$(ComputedAssemblyName)" />