project64/Directory.Build.targets

32 lines
1.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project>
<Target Name="GetGitVersion" BeforeTargets="PrepareForBuild" Condition="'$(NeedsVersioning)'=='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>
<!-- TODO: Remove -->
<Message Importance="High" Text="git rev: [$(GitRevision)]" />
<Message Importance="High" Text="git rev short: [$(GitRevisionShort)]" />
<Message Importance="High" Text="git rev count: [$(GitRevisionCount)]" />
<ItemGroup>
<ClCompile>
<PreprocessorDefinitions>
%(PreprocessorDefinitions);
GIT_REVISION=$(GitRevision);
GIT_REVISION_SHORT=$(GitRevisionShort);
VERSION_BUILD=$(GitRevisionCount);
VERSION_BUILD_YEAR=$([System.DateTime]::Now.ToString(`yyyy`))
</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
</Target>
</Project>