build(tst-11): stop Windows builds stamping git stderr into InformationalVersion (NEXT-09)
MSBuildThisFileDirectory ends in a backslash, which escaped the closing quote of the Exec command on Windows; git then failed and, because the target runs with ContinueOnError + ConsoleToMSBuild (which mixes stderr into ConsoleOutput), the failure text was stamped as the source revision — an observed stamp read '0.1.2+fatal: cannot change to ...'. Append '.' to the quoted path so the trailing separator can no longer escape the quote, and gate SourceRevisionId on a short-SHA shape so no future git failure text can become the revision either. Windows verification runs on windev with the rest of this batch; macOS stamp confirmed unchanged (0.2.0+75c71ad).
This commit is contained in:
@@ -26,7 +26,10 @@
|
||||
<Target Name="StampSourceRevision"
|
||||
BeforeTargets="GetAssemblyVersion;GenerateAssemblyInfo"
|
||||
Condition="'$(SourceRevisionId)' == ''">
|
||||
<Exec Command="git -C "$(MSBuildThisFileDirectory)" rev-parse --short HEAD"
|
||||
<!-- The trailing "." is load-bearing: $(MSBuildThisFileDirectory) ends in a path
|
||||
separator, and on Windows that trailing backslash escapes the closing quote,
|
||||
mangling the command so git's stderr got stamped as the revision (NEXT-09). -->
|
||||
<Exec Command="git -C "$(MSBuildThisFileDirectory)." rev-parse --short HEAD"
|
||||
ConsoleToMSBuild="true"
|
||||
StandardOutputImportance="Low"
|
||||
ContinueOnError="true"
|
||||
@@ -34,7 +37,9 @@
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="_StampedGitSha" />
|
||||
</Exec>
|
||||
<PropertyGroup>
|
||||
<SourceRevisionId Condition="'$(_StampedGitSha)' != ''">$(_StampedGitSha.Trim())</SourceRevisionId>
|
||||
<!-- Accept only something that looks like a git short SHA; Exec's ConsoleOutput
|
||||
mixes in stderr, so any git failure text must never become the revision. -->
|
||||
<SourceRevisionId Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(_StampedGitSha.Trim())', '^[0-9a-f]{7,40}$'))">$(_StampedGitSha.Trim())</SourceRevisionId>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user