A better way to set the version into the VersionInfo.cs file
In my previous post I mentioned that I had written my own <setversion> task to set the file version number in the centralized VersionInfo.cs. I took another look at NAnt's built in tasks, and <asminfo> does exactly what I need. I just changed the NAnt build script to write out VersionInfo.cs like this:
<asminfo output="VersionInfo.cs" language="CSharp">
<imports>
<import name="System.Reflection" />
</imports>
<attributes>
<attribute type="AssemblyFileVersionAttribute" value="${label-to-apply}" />
</attributes>
</asminfo>
Which writes out:
using System.Reflection;
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
[assembly: AssemblyFileVersionAttribute("1.0.0.123")]
Perfect. I love throwing away my own custom code in favor of built-in stuff!