I am trying to have MSBuild generate a text file with a version number representing when the build was created.
Right now in my MSBuild task I have the following:
<Target Name="WriteBuildDate" AfterTargets="Compile">
<WriteLinesToFile File="buildversion.txt" Lines="$([System.DateTime]::UtcNow.Year).$([System.DateTime]::UtcNow.Month).$([System.DateTime]::UtcNow.Day).$([System.Math]::Floor($([System.DateTime]::UtcNow.Subtract($([System.DateTime]::UtcNow.Date)).TotalSeconds)))" Overwrite="true" Encoding="Unicode" />
</Target>
This works, except that it executes even if the all assemblies were not rebuilt. This means if I use the VS publish capability for multiple servers each of them will have slightly different version numbers, even though the builds are all the same.
Is there any way (without custom msbuild tasks) to have this target only execute if at least one assembly was rebuilt?