Create a git log from msbuild

I have a weird problem with msbuild and git, I have a target in msbuild where I create a file that contains commits on git, but the target doesn't work when msbuild runs it ... I want to take a snapshot of the task to show that I am doing:


  Command='&quot;$(GitRunner)&quot; log --full-history --pretty=format:&quot;$(GitLogFormat)&quot; > $(GitLogPath)'


This will output the command:

"C:\Program Files (x86)\Git\bin\git.exe" log --full-history --pretty=format:"%H:%an:%cd:%B" > gitlog.xml


If I execute this from the command line (not msbuild), then the output of the gitlog file looks like this:

35b833f0133cee6bd749be6cc4dbb40c15ab1ff2:rewso:Sun Sep 14 12:16:51 2014 +0200:Main release_ContractManagement was commited local v: 0.17.2
0ca16d0c60768879cb876c1da8e9fb2e76ef6074:rewso:Sun Sep 14 11:29:16 2014 +0200:Main release_ContractManagement was commited local v: 0.16.2
fe14af5547f458dab069aa862c304e03136f0a94:rewso:Sun Sep 14 01:08:15 2014 +0200:Main release_ContractManagement was commited local v: 0.15.2


But if I do it from msbuild the gitlog file output is:



How can I get the same output when I use msbuild ??


source to share

1 answer

The% character must be escaped twice. The same problem happened once, and I don't remember why exactly this is needed twice; it may have something to do with Exec or the underlying cmd process% as a symbol used for environment variables.

Anyway, this should do it:





All Articles