Skip to content

Commit 5762536

Browse files
authored
[Build] Fix GitInfo usage to calculate version (#501)
* Update regex tag * Update reg for tag * Don't compare gitbranch * Update GitInfo * Add GitIgnoreBranchVersion * correct value * Test set GitIgnoreTagVersion * Fix GitIgnoreTagVersion
1 parent 8e8eea4 commit 5762536

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Diff for: eng/Git.Build.targets

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<ItemGroup>
3-
<PackageReference Include="GitInfo" Version="2.0.26" PrivateAssets="All" />
4-
<PackageReference Include="MSBuilder.GenerateAssemblyInfo" Version="0.2.1" PrivateAssets="All" />
3+
<PackageReference Include="GitInfo" Version="2.1.2" PrivateAssets="All" />
4+
<PackageReference Include="MSBuilder.GenerateAssemblyInfo" Version="0.2.2" PrivateAssets="All" />
55
</ItemGroup>
66
</Project>

Diff for: eng/Version.targets

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<NightlyTag>nightly</NightlyTag>
4-
<RegexPre>pre\d</RegexPre>
4+
<RegexTag>[a-z]+\.[0-9]</RegexTag>
55
</PropertyGroup>
66
<PropertyGroup>
77
<GitBranch Condition="'$(SYSTEM_PULLREQUEST_TARGETBRANCH)' != ''">$(SYSTEM_PULLREQUEST_TARGETBRANCH)</GitBranch>
@@ -33,10 +33,26 @@
3333
GitVersion;
3434
$(SetVersionsDependsOn);
3535
</SetVersionsDependsOn>
36+
<SetGitInfoPropsBefore>
37+
GitInfo;
38+
GitVersion;
39+
</SetGitInfoPropsBefore>
3640
</PropertyGroup>
3741

42+
<Target Name="SetGitInfoProps" BeforeTargets="$(SetGitInfoPropsBefore)">
43+
<PropertyGroup>
44+
<GitDefaultBranch>main</GitDefaultBranch>
45+
<GitIgnoreBranchVersion>true</GitIgnoreBranchVersion>
46+
<GitIgnoreTagVersion>true</GitIgnoreTagVersion>
47+
</PropertyGroup>
48+
</Target>
3849
<Target Name="SetVersions" BeforeTargets="$(SetVersionsBefore)" DependsOnTargets="$(SetVersionsDependsOn)" Returns="$(Version)">
3950
<PropertyGroup>
51+
<SemVerLabel>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(RegexTag)))</SemVerLabel>
52+
<GitDefaultBranch>main</GitDefaultBranch>
53+
<GitIgnoreBranchVersion>true</GitIgnoreBranchVersion>
54+
<GitIgnoreTagVersion>true</GitIgnoreTagVersion>
55+
<GitSemVerLabel Condition=" '$(GitTag)' != '' and $([System.Text.RegularExpressions.Regex]::IsMatch('$(GitTag)', $(RegexTag))) ">$(SemVerLabel)</GitSemVerLabel>
4056
<GitSemVerLabel Condition="$(CI) and '$(BUILD_REASON)' == 'Schedule'">$(NightlyTag)</GitSemVerLabel>
4157
<GitSemVerDashLabel Condition="'$(GitSemVerLabel)' != ''" >-$(GitSemVerLabel)</GitSemVerDashLabel>
4258
</PropertyGroup>

0 commit comments

Comments
 (0)