52 lines
2.5 KiB
XML
52 lines
2.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project>
|
|
|
|
<Target Name="GetGitVersion" BeforeTargets="PrepareForBuild" Condition="'$(GetGitVersionSet)'!='true'">
|
|
<Exec Command="git rev-parse HEAD" ConsoleToMsBuild="true" StandardOutputImportance="Low" EchoOff="true">
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitRevision" />
|
|
</Exec>
|
|
<Exec Command="git rev-parse --short HEAD" ConsoleToMsBuild="true" StandardOutputImportance="Low" EchoOff="true">
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitRevisionShort" />
|
|
</Exec>
|
|
<Exec Command="git rev-list --count HEAD" ConsoleToMsBuild="true" StandardOutputImportance="Low" EchoOff="true">
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitRevisionCount" />
|
|
</Exec>
|
|
<Exec Command="git diff --stat" ConsoleToMsBuild="true" StandardOutputImportance="Low" EchoOff="true">
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitIsDirty" />
|
|
</Exec>
|
|
<PropertyGroup>
|
|
<!-- Call only once per MSBuild invocation. -->
|
|
<GetGitVersionSet>true</GetGitVersionSet>
|
|
<GitVersion>$(GitRevisionShort)</GitVersion>
|
|
<GitVersion Condition="'$(GitIsDirty)'!=''">$(GitRevisionShort)-Dirty</GitVersion>
|
|
<GitPreprocessorDefinitions>
|
|
GIT_REVISION=$(GitRevision);
|
|
GIT_REVISION_SHORT=$(GitRevisionShort);
|
|
GIT_VERSION=$(GitVersion);
|
|
VERSION_BUILD=$(GitRevisionCount);
|
|
VERSION_BUILD_YEAR=$([System.DateTime]::Now.ToString(`yyyy`))
|
|
</GitPreprocessorDefinitions>
|
|
</PropertyGroup>
|
|
<Message Importance="Low" Text="git rev: [$(GitRevision)]" />
|
|
<Message Importance="Low" Text="git rev short: [$(GitRevisionShort)]" />
|
|
<Message Importance="Low" Text="git rev count: [$(GitRevisionCount)]" />
|
|
<Message Importance="Low" Text="git dirty?: [YES]" Condition="'$(GitIsDirty)'!=''" />
|
|
<Message Importance="Low" Text="git dirty?: []" Condition="'$(GitIsDirty)'==''" />
|
|
<Message Importance="Low" Text="GitVersion: [$(GitVersion)]" />
|
|
<ItemGroup>
|
|
<ClCompile>
|
|
<PreprocessorDefinitions>
|
|
%(PreprocessorDefinitions);
|
|
$(GitPreprocessorDefinitions)
|
|
</PreprocessorDefinitions>
|
|
</ClCompile>
|
|
<ResourceCompile>
|
|
<PreprocessorDefinitions>
|
|
%(PreprocessorDefinitions);
|
|
$(GitPreprocessorDefinitions)
|
|
</PreprocessorDefinitions>
|
|
</ResourceCompile>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
</Project> |