I’m sure you guys can probably relate to this, you check in a fix and tester comes back to you and says it still doesn’t work and you are like what the hell it works on my machine, after some digging you find the correct binaries did not get deployed

Just wanted to show you a neat little thing we implemented to link build number from build server to assembly file version

Add a new “AssemblyInfo.cs” file to your source folder of your solution and name it “SharedAssemblyInfo.cs”

Add the Assembly file version attribute to this file and add this file as linked file to all your projects within your solution

[assembly: AssemblyFileVersion("1.0.0.0")]

Next step is setting the AssemblyFileVersion attribute with build number value from build server in msbuild script before projects are built.

<PropertyGroup>

    <AssemblyFileVersion Condition="'$(BUILD_NUMBER)' != '' ">$(BUILD_NUMBER)</AssemblyFileVersion> <!-- make sure in teambuild this parameter is set as build arguments -->

</PropertyGroup>

<Target Name="SetAssemblyFileVersionWithBuildNumber">
    <WriteLinesToFile File="$(SrcDir)\SharedAssemblyInfo.cs" Lines="[assembly:AssemblyFileVersion(&quot;$(AssemblyFileVersion)&quot;)]" Overwrite="true"/>
  </Target>

Technorati Tags: ,