我正在尝试将 Git checkin 添加到我的 MSBuild 脚本中。我想:
- 通过消息提交文件
- 推送提交
- 标记构建
- 推送标签
构建脚本位于 ./Build/(其中 . 是解决方案文件夹)。
我正在使用:
<Target Name="Committed" DependsOnTargets="SignedInstaller">
<Exec Command=""$(GitInstallationFolderPath)cmd\git.exe" --git-dir=..\.git --work-tree=.. commit -m "$(Changes)""/>
<Exec Command=""$(GitInstallationFolderPath)cmd\git.exe" --git-dir=..\.git --work-tree=.. push"/>
<Exec Command=""$(GitInstallationFolderPath)cmd\git.exe" --git-dir=..\.git --work-tree=.. tag -a v$(VersionNumber) -m "$(Changes)""/>
<Exec Command=""$(GitInstallationFolderPath)cmd\git.exe" --git-dir=..\.git --work-tree=.. push -- tags"/>
</Target>
自定义属性都OK。
第一个提交以 1 退出并中断构建。
我不确定我是否只需要对此进行调整,或者我是否做错了,所以欢迎提供建议。我也需要做一些事情来将任何新文件添加到 Git - 只是还没到那一步。我确实想坚持使用 MSBuild,尽管我们现在有很多脚本。我只想删除我的 SVN 目标并移动到 Git。
最佳答案
与 MSBuild Extensions 中 GitTasks 的有限功能不同,Community Tasks 中似乎有更多通用的东西.
GitBranch A task to get the name of the branch or tag of git repository
GitClient A task for Git commands.
GitCommits A task for git to retrieve the number of commits on a revision.
GitDescribe A task for git to get the most current tag, commit count since tag, and commit hash.
GitPendingChanges A task for git to detect if there are pending changes
GitVersion A task for git to get the current commit hash.
关于git - 如何将 Git 添加到 MSBuild 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21209644/