2017-02-08 22:02:29 +00:00
|
|
|
<Project ToolsVersion="15.0">
|
2017-03-03 02:46:08 +00:00
|
|
|
<Target Name="WriteGitCommitInfoProps">
|
|
|
|
<Exec Command="git rev-list --count HEAD"
|
|
|
|
ConsoleToMSBuild="true">
|
|
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitCount" />
|
|
|
|
</Exec>
|
2017-02-10 20:13:44 +00:00
|
|
|
|
2017-03-03 02:46:08 +00:00
|
|
|
<Exec Command="git rev-parse HEAD"
|
|
|
|
ConsoleToMSBuild="true">
|
|
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitHash" />
|
|
|
|
</Exec>
|
2017-02-08 22:02:29 +00:00
|
|
|
|
2017-03-07 21:22:13 +00:00
|
|
|
<ItemGroup>
|
|
|
|
<GitInfoCommitCountLines Include="$(GitInfoCommitCount)" />
|
|
|
|
<GitInfoCommitHashLines Include="$(GitInfoCommitHash)" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
2017-02-08 22:02:29 +00:00
|
|
|
<PropertyGroup>
|
2017-03-07 21:22:13 +00:00
|
|
|
<!-- Batching in GitInfoCommitCount and GitInfoCommitHash here ensures that the property contains only the last line of the output -->
|
|
|
|
<GitInfoCommitCount>%(GitInfoCommitCountLines.Identity)</GitInfoCommitCount>
|
2017-03-07 19:04:18 +00:00
|
|
|
<GitInfoCommitCount>$(GitInfoCommitCount.PadLeft(6,'0'))</GitInfoCommitCount>
|
2017-03-07 18:49:28 +00:00
|
|
|
|
2017-03-07 21:22:13 +00:00
|
|
|
<GitInfoCommitHash>%(GitInfoCommitHashLines.Identity)</GitInfoCommitHash>
|
|
|
|
|
2017-02-08 22:02:29 +00:00
|
|
|
<GitCommitInfoPropsContent>
|
2017-09-05 21:44:25 +00:00
|
|
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2017-02-08 22:02:29 +00:00
|
|
|
<PropertyGroup>
|
2017-02-13 21:06:30 +00:00
|
|
|
<CommitCount>$(GitInfoCommitCount)</CommitCount>
|
2017-02-08 22:02:29 +00:00
|
|
|
<CommitHash>$(GitInfoCommitHash)</CommitHash>
|
|
|
|
</PropertyGroup>
|
|
|
|
</Project>
|
|
|
|
</GitCommitInfoPropsContent>
|
2017-03-08 19:10:53 +00:00
|
|
|
|
|
|
|
<ExistingGitCommitInfoProps Condition=" Exists('$(GitCommitInfoProps)') ">
|
|
|
|
$([System.IO.File]::ReadAllText($(GitCommitInfoProps)))
|
|
|
|
</ExistingGitCommitInfoProps>
|
|
|
|
|
|
|
|
<ShouldOverwriteGitCommitInfoPropsFile>false</ShouldOverwriteGitCommitInfoPropsFile>
|
|
|
|
<ShouldOverwriteGitCommitInfoPropsFile
|
|
|
|
Condition=" '$(ExistingGitCommitInfoProps.Trim())' != '$(GitCommitInfoPropsContent.Trim())' ">true</ShouldOverwriteGitCommitInfoPropsFile>
|
2017-02-08 22:02:29 +00:00
|
|
|
</PropertyGroup>
|
2017-03-07 20:02:47 +00:00
|
|
|
|
2017-02-08 22:02:29 +00:00
|
|
|
<WriteLinesToFile File="$(GitCommitInfoProps)"
|
|
|
|
Lines="$(GitCommitInfoPropsContent)"
|
2017-03-08 19:10:53 +00:00
|
|
|
Condition=" '$(ShouldOverwriteGitCommitInfoPropsFile)' == 'true' "
|
2017-02-09 18:50:21 +00:00
|
|
|
Overwrite="true" />
|
2017-02-08 22:02:29 +00:00
|
|
|
</Target>
|
|
|
|
</Project>
|