Templates: stamp engine version without build metadata (generated csproj referenced 4.4.0-beta5+g34c7f40f)

This commit is contained in:
Virgile Bello
2026-09-05 14:28:19 +09:00
parent 37812f206a
commit 7cbc828fee
3 changed files with 11 additions and 2 deletions
+4 -1
View File
@@ -16,6 +16,9 @@
<_StridePackagePublicVersion>$(_StridePackageMajorMinor).$(_StridePackagePatch)</_StridePackagePublicVersion>
<StrideNuGetVersionSuffix>$([System.Text.RegularExpressions.Regex]::Match($(_StrideSharedAssemblyInfoLines), `.*NuGetVersionSuffix = \"(.*)\";.*`).Groups[1].Value)</StrideNuGetVersionSuffix>
<StrideBuildMetadata>$([System.Text.RegularExpressions.Regex]::Match($(_StrideSharedAssemblyInfoLines), `.*BuildMetadata = \"(.*)\";.*`).Groups[1].Value)</StrideBuildMetadata>
<StrideNuGetVersion>$(_StridePackagePublicVersion)$(StrideNuGetVersionSuffix)$(StrideBuildMetadata)</StrideNuGetVersion>
<!-- WithoutMetadata is the version consumers reference (feeds normalize the +metadata away); the full
version (with the git hash on package builds) is only for the produced packages themselves. -->
<StrideNuGetVersionWithoutMetadata>$(_StridePackagePublicVersion)$(StrideNuGetVersionSuffix)</StrideNuGetVersionWithoutMetadata>
<StrideNuGetVersion>$(StrideNuGetVersionWithoutMetadata)$(StrideBuildMetadata)</StrideNuGetVersion>
</PropertyGroup>
</Project>
@@ -77,7 +77,7 @@
from PackageVersion: content-versioned packages (Samples/Starters) follow StrideSamplesVersion,
but their PackageReferences must name engine packages that actually exist. -->
<PropertyGroup>
<_StrideTemplatesEngineVersion>$(StrideNuGetVersion)</_StrideTemplatesEngineVersion>
<_StrideTemplatesEngineVersion>$(StrideNuGetVersionWithoutMetadata)</_StrideTemplatesEngineVersion>
<_StrideTemplatesEngineVersion Condition="'$(StrideWorktreeSuffix)' != '' And !$(_StrideTemplatesEngineVersion.EndsWith('$(StrideWorktreeSuffix)'))">$(_StrideTemplatesEngineVersion)$(StrideWorktreeSuffix)</_StrideTemplatesEngineVersion>
</PropertyGroup>
</Target>
@@ -151,6 +151,12 @@ public class StrideGameTemplateSmokeTests
var csprojText = File.ReadAllText(libraryCsproj);
Assert.True(csprojText.Contains("<PackageReference Include=\"Stride.Engine\""),
$"Generated {Path.GetFileName(libraryCsproj)} missing Stride.Engine PackageReference:\n{csprojText}");
// Build metadata (+g<sha> on release builds) must not leak into the stamped version.
var version = System.Text.RegularExpressions.Regex.Match(csprojText, "Stride\\.Engine\"\\s+Version=\"([^\"]+)\"");
Assert.True(version.Success && version.Groups[1].Value.Length > 0,
$"Generated {Path.GetFileName(libraryCsproj)} has no version on its Stride.Engine PackageReference:\n{csprojText}");
Assert.DoesNotContain("+", version.Groups[1].Value);
}
/// <summary>