diff --git a/src/Agent/AutopilotMonitor.Agent/SelfUpdater.cs b/src/Agent/AutopilotMonitor.Agent/SelfUpdater.cs
index cfb4bf94..97da53bf 100644
--- a/src/Agent/AutopilotMonitor.Agent/SelfUpdater.cs
+++ b/src/Agent/AutopilotMonitor.Agent/SelfUpdater.cs
@@ -188,17 +188,35 @@ namespace AutopilotMonitor.Agent
///
/// Compares two version strings. Returns true if latest is newer than current.
+ /// Strips SemVer suffixes (+metadata, -prerelease) before parsing because
+ /// System.Version cannot handle them (e.g. "1.0.386+b7f8d3c..." would fail).
///
private static bool IsNewerVersion(string current, string latest)
{
- if (!Version.TryParse(current, out var currentVer))
+ if (!Version.TryParse(StripVersionSuffix(current), out var currentVer))
return false;
- if (!Version.TryParse(latest, out var latestVer))
+ if (!Version.TryParse(StripVersionSuffix(latest), out var latestVer))
return false;
return latestVer > currentVer;
}
+ private static string StripVersionSuffix(string version)
+ {
+ if (string.IsNullOrEmpty(version))
+ return version;
+
+ var plusIndex = version.IndexOf('+');
+ if (plusIndex >= 0)
+ version = version.Substring(0, plusIndex);
+
+ var dashIndex = version.IndexOf('-');
+ if (dashIndex >= 0)
+ version = version.Substring(0, dashIndex);
+
+ return version;
+ }
+
///
/// Downloads the agent ZIP to a temp path. Returns false on failure.
///
diff --git a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt
index 2c60641d..6f8a8c5e 100644
--- a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt
+++ b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt
@@ -1 +1 @@
-388
+390