45a1e9e56c
* Allow host info passed in from the command line to override machine settings * Simplify the logic * Address PR comments to keep a separate HostRid and HostOSName that are static * Rename to BuildInfo.props * Address PR comments * Fix the previous merge * Fix spacing * Address PR comments
48 lines
2 KiB
XML
48 lines
2 KiB
XML
<Project ToolsVersion="15.0">
|
|
<Target Name="WriteGitCommitInfoProps">
|
|
<Exec Command="git rev-list --count HEAD"
|
|
ConsoleToMSBuild="true">
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitCount" />
|
|
</Exec>
|
|
|
|
<Exec Command="git rev-parse HEAD"
|
|
ConsoleToMSBuild="true">
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitHash" />
|
|
</Exec>
|
|
|
|
<ItemGroup>
|
|
<GitInfoCommitCountLines Include="$(GitInfoCommitCount)" />
|
|
<GitInfoCommitHashLines Include="$(GitInfoCommitHash)" />
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup>
|
|
<!-- Batching in GitInfoCommitCount and GitInfoCommitHash here ensures that the property contains only the last line of the output -->
|
|
<GitInfoCommitCount>%(GitInfoCommitCountLines.Identity)</GitInfoCommitCount>
|
|
<GitInfoCommitCount>$(GitInfoCommitCount.PadLeft(6,'0'))</GitInfoCommitCount>
|
|
|
|
<GitInfoCommitHash>%(GitInfoCommitHashLines.Identity)</GitInfoCommitHash>
|
|
|
|
<GitCommitInfoPropsContent>
|
|
<Project ToolsVersion="15.0">
|
|
<PropertyGroup>
|
|
<CommitCount>$(GitInfoCommitCount)</CommitCount>
|
|
<CommitHash>$(GitInfoCommitHash)</CommitHash>
|
|
</PropertyGroup>
|
|
</Project>
|
|
</GitCommitInfoPropsContent>
|
|
|
|
<ExistingGitCommitInfoProps Condition=" Exists('$(GitCommitInfoProps)') ">
|
|
$([System.IO.File]::ReadAllText($(GitCommitInfoProps)))
|
|
</ExistingGitCommitInfoProps>
|
|
|
|
<ShouldOverwriteGitCommitInfoPropsFile>false</ShouldOverwriteGitCommitInfoPropsFile>
|
|
<ShouldOverwriteGitCommitInfoPropsFile
|
|
Condition=" '$(ExistingGitCommitInfoProps.Trim())' != '$(GitCommitInfoPropsContent.Trim())' ">true</ShouldOverwriteGitCommitInfoPropsFile>
|
|
</PropertyGroup>
|
|
|
|
<WriteLinesToFile File="$(GitCommitInfoProps)"
|
|
Lines="$(GitCommitInfoPropsContent)"
|
|
Condition=" '$(ShouldOverwriteGitCommitInfoPropsFile)' == 'true' "
|
|
Overwrite="true" />
|
|
</Target>
|
|
</Project>
|