-
Notifications
You must be signed in to change notification settings - Fork 3
/
Directory.Build.targets
28 lines (28 loc) · 1.02 KB
/
Directory.Build.targets
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
<Project>
<Target
Name="SetVersions"
BeforeTargets="GetAssemblyVersion;GetPackageVersion;InitializeSourceControlInformation"
Returns="Version">
<Exec
Command="git for-each-ref --sort=taggerdate --format '%25(refname)' refs/tags"
ConsoleToMSBuild="true"
StandardOutputImportance="low">
<Output TaskParameter="ConsoleOutput" ItemName="GitOutput"/>
</Exec>
<ItemGroup>
<GitTag
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(%(Filename)%(Extension), '^v\d+\.\d+\.\d+(-\w+)?$'))"
Include="$([System.String]::Copy(%(GitOutput.Filename)%(GitOutput.Extension)).Substring(1))"/>
</ItemGroup>
<PropertyGroup>
<PackageVersion>%(GitTag.Identity)</PackageVersion>
</PropertyGroup>
<PropertyGroup>
<PackageVersion Condition="'$(PackageVersion)' == ''">0.0.0</PackageVersion>
<Version>$(PackageVersion)</Version>
</PropertyGroup>
<Message
Text="PackageVersion: $(PackageVersion)"
Importance="high"/>
</Target>
</Project>