• Continuous Integration,  MSBuild

    Writing MSBuild Custom Task

    Scenario: we have Subversion server to manage our source code and a build server (CruiseControl.NET) to manage our deployment. We have decided to automatically set the SVN revision number to our assembly version. [assembly: System.Reflection.AssemblyVersion("1.2.3.0")] [assembly: System.Reflection.AssemblyFileVersion("1.2.3.0")] So we will replace the last 0 with the current Subversion revision number. How to do this? One way to achieve this is to modify the AssemblyInfo.cs and read the modified number from that exists. The file modification is easy with MSBuild Community Task FileUpdate <FileUpdate Files="Cic.P001001PropertiesAssemblyInfo.cs" Regex="(d+).(d+).(d+).(d+)" ReplacementText="$1.$2.$3.$(RevisionNumber)" /> But how to read it back? Well there is no easy way. I have written a custom MSBuidl task to achieve this like…