如何将Git添加到MSBuild脚本?

时间:2014-01-18 20:44:50

标签: git visual-studio msbuild

我正在尝试添加Git签到作为我的MSBuild脚本的一部分。我想:

  1. 使用消息提交文件
  2. 推送提交
  3. 标记构建
  4. 推送标签
  5. 构建脚本位于./Build/(其中。是解决方案文件夹)。

    我正在使用:

    <Target Name="Committed" DependsOnTargets="SignedInstaller">
      <Exec Command="&quot;$(GitInstallationFolderPath)cmd\git.exe&quot; --git-dir=..\.git --work-tree=.. commit -m &quot;$(Changes)&quot;"/>
      <Exec Command="&quot;$(GitInstallationFolderPath)cmd\git.exe&quot; --git-dir=..\.git --work-tree=.. push"/>
      <Exec Command="&quot;$(GitInstallationFolderPath)cmd\git.exe&quot; --git-dir=..\.git --work-tree=.. tag -a v$(VersionNumber) -m &quot;$(Changes)&quot;"/>
      <Exec Command="&quot;$(GitInstallationFolderPath)cmd\git.exe&quot; --git-dir=..\.git --work-tree=.. push -- tags"/>
    </Target>  
    

    自定义属性都可以。

    第一次提交以1退出并打破构建。

    我不确定我是否只需要调整一下,或者如果我认为这一切都错了,那么欢迎提出建议。我需要做一些向Git添加任何新文件 - 还没有那么远。我确实想坚持使用MSBuild,因为我们现在有很多脚本。我只想删除我的SVN目标并转移到Git。

1 个答案:

答案 0 :(得分:1)

与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.