Skip to content

Commit 297a561

Browse files
committed
Fixed problems with white space in some of the values before they are generated
1 parent aa5cb92 commit 297a561

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/build/Versioning.Common.targets

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<Message Importance="Low" Text="BuildIdentifier already set by user: $(BuildIdentifier)" />
4747
</Target>
4848

49+
<!-- Make the BuildIdentifier from GIT -->
4950
<Target Name="SetBuildIdentifierFromGit"
5051
BeforeTargets="SetBuildIdentifierFromTFVC;Versioning-Common-LogSelectedVersion"
5152
Condition="'$(BuildIdentifier)' == ''">
@@ -65,10 +66,15 @@
6566

6667
<!-- Fallback if git fails -->
6768
<PropertyGroup>
68-
<BuildIdentifier Condition="'$(GitCommitSha)' != '' and '$(BuildIdentifier)' == ''">git-$(GitCommitSha)</BuildIdentifier>
69+
<GitCommitSha Condition="'$(GitCommitSha)' != ''">$([System.Text.RegularExpressions.Regex]::Replace('$(GitCommitSha)', '\s+', ''))</GitCommitSha>
70+
</PropertyGroup>
71+
72+
<PropertyGroup>
73+
<BuildIdentifier Condition="'$(GitCommitSha)' != ''">git-$(GitCommitSha)</BuildIdentifier>
6974
</PropertyGroup>
7075
</Target>
7176

77+
<!-- Make the BuildIdentifier from TFVC (Microsoft DevOps) if it did not -->
7278
<Target Name="SetBuildIdentifierFromTFVC"
7379
BeforeTargets="SetBuildIdentifierFromSVN;Versioning-Common-LogSelectedVersion"
7480
Condition="'$(BuildIdentifier)' == '' AND '$(GitCommitSha)' == ''">
@@ -87,13 +93,16 @@
8793

8894
<!-- Extract the changeset ID (first line usually contains it) -->
8995
<PropertyGroup>
90-
<TFVC_Changeset Condition="'$(TFVC_History)' != ''">
91-
$([System.Text.RegularExpressions.Regex]::Match('$(TFVC_History)', 'Changeset:\s*(\d+)').Groups[1].Value)
92-
</TFVC_Changeset>
93-
<BuildIdentifier Condition="'$(TFVC_Changeset)' != ''">tfvc-$(TFVC_Changeset)</BuildIdentifier>
96+
<TFVC_Changeset Condition="'$(TFVC_History)' != ''">$([System.Text.RegularExpressions.Regex]::Match('$(TFVC_History)', 'Changeset:\s*(\d+)').Groups[1].Value)</TFVC_Changeset>
97+
98+
<!-- Clean out whitespace just in case -->
99+
<TFVC_Changeset>$([System.Text.RegularExpressions.Regex]::Replace('$(TFVC_Changeset)', '\s+', ''))</TFVC_Changeset>
100+
101+
<BuildIdentifier Condition="'$(TFVC_Changeset)' != ''">tfvc-cs$(TFVC_Changeset)</BuildIdentifier>
94102
</PropertyGroup>
95103
</Target>
96104

105+
<!-- Make the BuildIdentifier from SVN if we did not get it from Git or TFVC -->
97106
<Target Name="SetBuildIdentifierFromSVN"
98107
BeforeTargets="_SetInformationalVersionVariable;Versioning-Common-LogSelectedVersion"
99108
Condition="'$(BuildIdentifier)' == '' AND '$(GitCommitSha)' == '' AND '$(TFVC_Changeset)' == ''">
@@ -111,6 +120,10 @@
111120
<Output TaskParameter="Lines" PropertyName="SVNRevision" />
112121
</ReadLinesFromFile>
113122

123+
<PropertyGroup>
124+
<SVNRevision Condition="'$(SVNRevision)' != ''">$([System.Text.RegularExpressions.Regex]::Replace('$(SVNRevision)', '\s+', ''))</SVNRevision>
125+
</PropertyGroup>
126+
114127
<PropertyGroup>
115128
<BuildIdentifier Condition="'$(SVNRevision)' != ''">svn-r$(SVNRevision)</BuildIdentifier>
116129
<BuildIdentifier Condition="'$(BuildIdentifier)' == ''">noscm</BuildIdentifier>

0 commit comments

Comments
 (0)