I am trying to execute this simple command from MSBuild (VS2015, from a .target
file) to generate the date of the current git commit:
git show -s --format=%cd --date=format:%d.%m.%Y
So in MSBuild I have tried:
<Exec Command="git show -s --format=%25cd --date=format:%25d.%25m.%25Y" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="BuildDate" />
</Exec>
But it yields only an error:
1>------ Build started: Project: example, Configuration: Release Dll Win32 ------
1> fatal: invalid --pretty format: d.Y
1>D:\example\gitversion.targets(26,5): error MSB3073: The command "git show -s --format=%cd --date=format:%d.%m.%Y" exited with code 128.
If I post the command within the quotation marks to the console, it works like a charm and prints 19.12.2016
.
I have tried the following things:
Escape also the
=
sign,:
, ... still does not workUse only
Command="git show -s --format=%25ci"
-> yields also an errorfatal: invalid --pretty format: ci
but works fine in console.surround with quotes
"--format=%25ci"
-> same errorCall with
Command="git --version"
, this works as expected and returns the git version (same as on console)
I suspect that it somehow does not accept the =
to specify the argument, but git won't let me pass it as separate arguments, e.g. separated by a space.