|
46 | 46 | <Message Importance="Low" Text="BuildIdentifier already set by user: $(BuildIdentifier)" /> |
47 | 47 | </Target> |
48 | 48 |
|
| 49 | + <!-- Make the BuildIdentifier from GIT --> |
49 | 50 | <Target Name="SetBuildIdentifierFromGit" |
50 | 51 | BeforeTargets="SetBuildIdentifierFromTFVC;Versioning-Common-LogSelectedVersion" |
51 | 52 | Condition="'$(BuildIdentifier)' == ''"> |
|
65 | 66 |
|
66 | 67 | <!-- Fallback if git fails --> |
67 | 68 | <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> |
69 | 74 | </PropertyGroup> |
70 | 75 | </Target> |
71 | 76 |
|
| 77 | + <!-- Make the BuildIdentifier from TFVC (Microsoft DevOps) if it did not --> |
72 | 78 | <Target Name="SetBuildIdentifierFromTFVC" |
73 | 79 | BeforeTargets="SetBuildIdentifierFromSVN;Versioning-Common-LogSelectedVersion" |
74 | 80 | Condition="'$(BuildIdentifier)' == '' AND '$(GitCommitSha)' == ''"> |
|
87 | 93 |
|
88 | 94 | <!-- Extract the changeset ID (first line usually contains it) --> |
89 | 95 | <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> |
94 | 102 | </PropertyGroup> |
95 | 103 | </Target> |
96 | 104 |
|
| 105 | + <!-- Make the BuildIdentifier from SVN if we did not get it from Git or TFVC --> |
97 | 106 | <Target Name="SetBuildIdentifierFromSVN" |
98 | 107 | BeforeTargets="_SetInformationalVersionVariable;Versioning-Common-LogSelectedVersion" |
99 | 108 | Condition="'$(BuildIdentifier)' == '' AND '$(GitCommitSha)' == '' AND '$(TFVC_Changeset)' == ''"> |
|
111 | 120 | <Output TaskParameter="Lines" PropertyName="SVNRevision" /> |
112 | 121 | </ReadLinesFromFile> |
113 | 122 |
|
| 123 | + <PropertyGroup> |
| 124 | + <SVNRevision Condition="'$(SVNRevision)' != ''">$([System.Text.RegularExpressions.Regex]::Replace('$(SVNRevision)', '\s+', ''))</SVNRevision> |
| 125 | + </PropertyGroup> |
| 126 | + |
114 | 127 | <PropertyGroup> |
115 | 128 | <BuildIdentifier Condition="'$(SVNRevision)' != ''">svn-r$(SVNRevision)</BuildIdentifier> |
116 | 129 | <BuildIdentifier Condition="'$(BuildIdentifier)' == ''">noscm</BuildIdentifier> |
|
0 commit comments