我对 msbuild 和 git 有一个奇怪的问题,我在 msbuild 中有一个目标,我在其中创建了一个包含对 git 的提交的文件,但是当 msbuild 运行它时目标不工作...... 我从任务中截取了一个片段来展示我在做什么:
<GitLogFormat>%25H:%25an:%25cd:%25B</GitLogFormat>
<GitLogPath>gitlog.xml</GitLogPath>
<Exec
Command='"$(GitRunner)" log --full-history --pretty=format:"$(GitLogFormat)" > $(GitLogPath)'
WorkingDirectory="$(GlobalRootPath)"
</Exec>
这将输出命令:
"C:\Program Files (x86)\Git\bin\git.exe" log --full-history --pretty=format:"%H:%an:%cd:%B" > gitlog.xml
如果我从命令行(不是 msbuild)执行它,那么 gitlog 文件的输出将如下所示:
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
但是如果我从 msbuild 执行此操作,gitlog 文件的输出将是:
an:B
an:B
an:B
我如何在使用 msbuild 时获得相同的输出??
最佳答案
% 字符需要转义两次。曾经遇到过同样的问题,但我不记得为什么需要两次了;它可能与 Exec 或底层 cmd 将 % 视为用于环境变量的字符有关。
无论如何,应该这样做:
<PropertyGroup>
<GitLogFormat>%25%25H:%25%25an:%25%25cd:%25%25B</GitLogFormat>
</PropertyGroup>
关于msbuild - 从 msbuild 创建 git 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25908312/