diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs
index de3bf127406..55e016d5ab4 100644
--- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs
+++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs
@@ -147,23 +147,33 @@ internal static async Task SourceAspireCliEnvironmentAsync(
}
///
- /// Verifies the installed Aspire CLI version matches the expected version.
+ /// Verifies the installed Aspire CLI version matches the expected build.
+ /// Always checks the dynamic version prefix from eng/Versions.props.
+ /// For non-stabilized builds (all normal PR builds), also verifies the commit SHA suffix.
///
-#pragma warning disable IDE0060 // commitSha is unused during stabilized builds — restore when merging back to main
internal static async Task VerifyAspireCliVersionAsync(
this Hex1bTerminalAutomator auto,
string commitSha,
SequenceCounter counter)
-#pragma warning restore IDE0060
{
+ var versionPrefix = CliE2ETestHelpers.GetVersionPrefix();
+ var isStabilized = CliE2ETestHelpers.IsStabilizedBuild();
+
await auto.TypeAsync("aspire --version");
await auto.EnterAsync();
- // When the build is stabilized (StabilizePackageVersion=true), the CLI version
- // is just "13.2.0" with no commit SHA suffix. When not stabilized, it includes
- // the SHA (e.g., "13.2.0-preview.1.g"). In both cases, "13.2.0" is present.
- // TODO: This change should be reverted on the integration to the main branch.
- await auto.WaitUntilTextAsync("13.2.0", timeout: TimeSpan.FromSeconds(10));
+ // Always verify the version prefix matches the branch's version (e.g., "13.3.0").
+ await auto.WaitUntilTextAsync(versionPrefix, timeout: TimeSpan.FromSeconds(10));
+
+ // For non-stabilized builds (all PR CI builds), also verify the commit SHA suffix
+ // to uniquely identify the exact build. Stabilized builds (official releases only)
+ // produce versions without SHA suffixes, so we skip this check.
+ if (!isStabilized && commitSha.Length == 40)
+ {
+ var shortCommitSha = commitSha[..8];
+ var expectedVersionSuffix = $"g{shortCommitSha}";
+ await auto.WaitUntilTextAsync(expectedVersionSuffix, timeout: TimeSpan.FromSeconds(10));
+ }
await auto.WaitForSuccessPromptAsync(counter);
}
diff --git a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs
index ed41c1a899b..2937fec507c 100644
--- a/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs
+++ b/tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.CompilerServices;
+using System.Xml.Linq;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Xunit;
@@ -309,4 +310,51 @@ internal static string ToContainerPath(string hostPath, TemporaryWorkspace works
var relativePath = Path.GetRelativePath(workspace.WorkspaceRoot.FullName, hostPath);
return $"/workspace/{workspace.WorkspaceRoot.Name}/" + relativePath.Replace('\\', '/');
}
+
+ ///
+ /// Reads the VersionPrefix (e.g., "13.3.0") from eng/Versions.props by parsing
+ /// the MajorVersion, MinorVersion, and PatchVersion MSBuild properties.
+ ///
+ internal static string GetVersionPrefix()
+ {
+ var repoRoot = GetRepoRoot();
+ var versionsPropsPath = Path.Combine(repoRoot, "eng", "Versions.props");
+
+ var doc = XDocument.Load(versionsPropsPath);
+ var ns = doc.Root?.Name.Namespace ?? XNamespace.None;
+
+ string? GetProperty(string name) =>
+ doc.Descendants(ns + name).FirstOrDefault()?.Value;
+
+ var major = GetProperty("MajorVersion")
+ ?? throw new InvalidOperationException("MajorVersion not found in eng/Versions.props");
+ var minor = GetProperty("MinorVersion")
+ ?? throw new InvalidOperationException("MinorVersion not found in eng/Versions.props");
+ var patch = GetProperty("PatchVersion")
+ ?? throw new InvalidOperationException("PatchVersion not found in eng/Versions.props");
+
+ return $"{major}.{minor}.{patch}";
+ }
+
+ ///
+ /// Checks whether the build is stabilized (StabilizePackageVersion=true in eng/Versions.props).
+ /// Stabilized builds produce version strings without commit SHA suffixes (e.g., "13.2.0" instead
+ /// of "13.2.0-preview.1.25175.1+g{sha}"). This is only true for official release builds,
+ /// never for normal PR CI builds.
+ ///
+ internal static bool IsStabilizedBuild()
+ {
+ var repoRoot = GetRepoRoot();
+ var versionsPropsPath = Path.Combine(repoRoot, "eng", "Versions.props");
+
+ var doc = XDocument.Load(versionsPropsPath);
+ var ns = doc.Root?.Name.Namespace ?? XNamespace.None;
+
+ // The default value in Versions.props uses a Condition to default to "false",
+ // so we read the element's text directly.
+ var stabilize = doc.Descendants(ns + "StabilizePackageVersion")
+ .FirstOrDefault()?.Value;
+
+ return string.Equals(stabilize, "true", StringComparison.OrdinalIgnoreCase);
+ }
}