Skip to content

Commit db052de

Browse files
committed
Prerelease version validation fix
1 parent dba6bff commit db052de

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Installer/Microsoft.Dotnet.Installation/Internal/ChannelVersionResolver.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ public static bool IsValidChannelFormat(string channel)
107107
return true;
108108
}
109109

110-
// Strip prerelease suffix (e.g., "10.0.100-preview.1.32640" -> "10.0.100")
110+
// Check for prerelease suffix (e.g., "10.0.100-preview.1.32640")
111111
var dashIndex = channel.IndexOf('-');
112-
var versionPart = dashIndex >= 0 ? channel.Substring(0, dashIndex) : channel;
112+
var hasPrerelease = dashIndex >= 0;
113+
var versionPart = hasPrerelease ? channel.Substring(0, dashIndex) : channel;
113114

114115
// Try to parse as a version-like string
115116
var parts = versionPart.Split('.');
@@ -142,10 +143,16 @@ public static bool IsValidChannelFormat(string channel)
142143
}
143144

144145
// Allow either:
145-
// - a fully specified numeric patch (e.g., "103"), or
146-
// - a feature band pattern with a numeric prefix and "xx" suffix (e.g., "1xx", "101xx").
146+
// - a fully specified numeric patch (e.g., "103"), optionally with a prerelease suffix, or
147+
// - a feature band pattern with a numeric prefix and "xx" suffix (e.g., "1xx", "101xx"),
148+
// but NOT with a prerelease suffix (wildcards with prerelease not supported).
147149
if (patch.EndsWith("xx", StringComparison.OrdinalIgnoreCase))
148150
{
151+
if (hasPrerelease)
152+
{
153+
return false;
154+
}
155+
149156
var prefix = patch.Substring(0, patch.Length - 2);
150157
if (prefix.Length == 0 || !int.TryParse(prefix, out _))
151158
{

0 commit comments

Comments
 (0)