xbuild

Write date to file with xbuild


I'm using xbuild 12 in monodevelop 5.9.6. Yes, it's old. No, I can't upgrade. :)

I want to write the current date to a file on build. I've set up something like this, by googling msbuild:

<Target Name="AfterBuild">
  <WriteLinesToFile File="$(OutputPath)\version.txt" Lines="$([System.DateTime]::Now.ToString())" Overwrite="true" />
</Target>

However when I build it in monodevelop, I get this error:

Error: Error executing task WriteLinesToFile: Error converting Property named 'Lines' with value '$([System.DateTime]::Now.ToString())' to type Microsoft.Build.Framework.ITaskItem[]: The requested feature is not implemented. (Server)

So it looks like I'm out of luck? Is there a functional way xbuild can do this? Preferably with some custom formatting. One fallback I could use is run a tiny python script instead, but it's starting to get Rube Goldbergy.


Solution

  • It seems this version doesn't support property functions. On Mac/linux you could use:

    <Target Name="AfterBuild">
        <Exec Command="date > $(OutputPath)\version.txt" /> 
    </Target>