-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
40 lines (34 loc) · 1.76 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
40 lines (34 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<Project>
<!-- Derive the assembly version from the nearest git release tag so the About
screen shows the actual build (e.g. "0.1.9-rc1-23-g13a9f8b") instead of the
default 1.0.0.0. Runs once per project before assembly-info generation.
Best-effort: if git is missing or the tree has no tags, the static
<Version> fallback from Directory.Build.props stands. -->
<Target Name="SetVersionFromGit"
BeforeTargets="GetAssemblyVersion;GenerateAssemblyInfo;CoreCompile"
Condition="'$(OpenIpcVersionResolved)' != 'true'">
<Exec Command="git describe --tags --always --dirty"
WorkingDirectory="$(MSBuildThisFileDirectory)"
ConsoleToMSBuild="true"
StandardOutputImportance="Low"
ContinueOnError="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_GitDescribe" />
<Output TaskParameter="ExitCode" PropertyName="_GitExit" />
</Exec>
<PropertyGroup Condition="'$(_GitExit)' == '0' and '$(_GitDescribe)' != ''">
<!-- Drop the leading "v" so "v0.1.9-rc1" → "0.1.9-rc1...". -->
<InformationalVersion>$(_GitDescribe.TrimStart('v'))</InformationalVersion>
<!-- Numeric core (X.Y.Z) for AssemblyVersion/FileVersion, which reject
pre-release/metadata suffixes. -->
<_GitNumeric>$([System.Text.RegularExpressions.Regex]::Match($(_GitDescribe), '[0-9]+\.[0-9]+\.[0-9]+').Value)</_GitNumeric>
</PropertyGroup>
<PropertyGroup Condition="'$(_GitNumeric)' != ''">
<Version>$(_GitNumeric)</Version>
<FileVersion>$(_GitNumeric).0</FileVersion>
<AssemblyVersion>$(_GitNumeric).0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<OpenIpcVersionResolved>true</OpenIpcVersionResolved>
</PropertyGroup>
</Target>
</Project>