In the end, I did this using NAnt xmlpoke, so for the version we ended up with 20.0.dayofyear.hourminute - this is mostly unique in assemblies.
There is no need for custom tasks, but a later version of MSBuild also has pokexml, so it can work with that.
<target name="pokerevision" depends="init"> <property name="projectname" value="MyProject.GUI" /> <property name="app.revision" value="${datetime::get-hour(datetime::now())}${datetime::get-minute(datetime::now())}" /> <echo message="revision: ${app.revision}" /> <xmlpoke file="${Solution.Path}\${projectname}\${projectname}.csproj" xpath="//x:Project/x:PropertyGroup[1]/x:ApplicationRevision" value="${app.revision}" > <namespaces> <namespace prefix="x" uri="http://schemas.microsoft.com/developer/msbuild/2003" /> </namespaces> </xmlpoke> <property name="app.version" value="20.0.${datetime::get-day-of-year(datetime::now())}.${app.revision}" /> <echo message="version: ${app.version}" /> <xmlpoke file="${Solution.Path}\${projectname}\${projectname}.csproj" xpath="//x:Project/x:PropertyGroup[1]/x:ApplicationVersion" value="${app.version}" > <namespaces> <namespace prefix="x" uri="http://schemas.microsoft.com/developer/msbuild/2003" /> </namespaces> </xmlpoke> </target>
Adam butler
source share