In my Software Needs post last year I left out something really important: Versioning.
We commonly face the problem where we do not know what functionality is contained within DLLs used in production. We can guess based on the created date – and we can decompile using tools such as Telerik’s Just Decompile – but we’re still guessing!
Instead we now use the build server to add the last SVN revision number to an assembly’s version number. By doing this we can be tie a DLL on disk to a specific commit in Source Control.
TeamCity will version assemblies for you. We use CruiseControl.Net however, so I knocked up little utility called from NAnt that modifies all AssemblyInfo.cs files within a given directory before the main build.
Here's the NAnt target, showing how to get the SVN revision:
We commonly face the problem where we do not know what functionality is contained within DLLs used in production. We can guess based on the created date – and we can decompile using tools such as Telerik’s Just Decompile – but we’re still guessing!
Instead we now use the build server to add the last SVN revision number to an assembly’s version number. By doing this we can be tie a DLL on disk to a specific commit in Source Control.
TeamCity will version assemblies for you. We use CruiseControl.Net however, so I knocked up little utility called from NAnt that modifies all AssemblyInfo.cs files within a given directory before the main build.
Here's the NAnt target, showing how to get the SVN revision:
<target name="SetVersion" depends="Clean"> <!-- write the last revision from SVN to a file --> <exec program="C:\Program Files (x86)\VisualSVN Server\bin\svn.exe" output="revision.xml"> <arg line="info --xml ${build.path}"/> </exec> <!-- get the manually incremented (major) version from a file in the repo --> <xmlpeek file="${build.path}\version.xml" xpath="/versions/baseversion" property="base.version"/> <!-- get the SVN revision we wrote in step 1 --> <xmlpeek file="revision.xml" xpath="/info/entry/commit/@revision" property="svn.revision"/> <!-- alter all AsssemblyInfo files in the directory --> <exec program="D:\AssemblyInfoVersioner\AssemblyInfoVersioner.exe"> <arg value="${build.path}" /> <arg value="/afv:${base.version}.${svn.revision}" /> </exec> <!-- save the full version for naming zip files and for tagging the repo later --> <xmlpoke file="${build.path}\version.xml" xpath="/versions/fullversion" value="${base.version}.${svn.revision}" /> </target>
Comments
Post a Comment