<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <GitWorkingBranch Condition="'$(GitWorkingBranch)' == ''">master</GitWorkingBranch>
    <GitPushRemote Condition="'$(GitPushRemote)' == ''">origin</GitPushRemote>
  </PropertyGroup>

  <Target Name="CommitBuildValues"
    AfterTargets="BuildPackages"
    Condition="'$(UpdateBuildValues)' == 'true'"
    >
    <!-- configure the commit to show up as the dotnet bot -->
    <Exec
      WorkingDirectory="$(SourceDir)"
      StandardOutputImportance="Low"
      Command="git config user.name &quot;dotnet-bot&quot;" />

    <Exec
      WorkingDirectory="$(SourceDir)"
      StandardOutputImportance="Low"
      Command="git config user.email &quot;dotnet-bot@microsoft.com&quot;" />

    <!-- commit and push to origin -->
    <Exec
      WorkingDirectory="$(SourceDir)"
      StandardOutputImportance="Low"
      Command="git checkout $(GitWorkingBranch)" />

    <Exec
      WorkingDirectory="$(SourceDir)"
      StandardOutputImportance="Low"
      Command="git commit -m &quot;Automated commit of revision number value $(RevisionNumber).&quot; $(SourceDir)BuildValues.props" />

    <Exec
      WorkingDirectory="$(SourceDir)"
      StandardOutputImportance="Low"
      Command="git push $(GitPushRemote) $(GitWorkingBranch)" />

  </Target>
</Project>
