Define GetGitVersion target

This commit is contained in:
Julio C. Rocha 2024-05-10 04:34:11 -07:00
parent 3cdd8ce0ff
commit 7ce6ca7110
2 changed files with 22 additions and 1 deletions

20
Directory.Build.targets Normal file
View File

@ -0,0 +1,20 @@
<?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)]" />
</Target>
</Project>

View File

@ -24,6 +24,7 @@
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<NeedsVersioning>true</NeedsVersioning>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ImportGroup Label="PropertySheets">
@ -33,7 +34,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>"$(SolutionDir)Source\Script\UpdateVersion.cmd" "$(Configuration)" "$(Platform)" "$(SolutionDir)Source\Project64-rsp-core\Version.h.in" "$(SolutionDir)Source\Project64-rsp-core\Version.h"</Command>
<!-- <Command>"$(SolutionDir)Source\Script\UpdateVersion.cmd" "$(Configuration)" "$(Platform)" "$(SolutionDir)Source\Project64-rsp-core\Version.h.in" "$(SolutionDir)Source\Project64-rsp-core\Version.h"</Command> -->
</PreBuildEvent>
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>