Ich habe diesen C# Code
Console.WriteLine("[info] Vergleiche installierte und verfügbare Versionen...\n");
foreach (var installed in installedPackages)
{
var repoPkg = repoPackages.FirstOrDefault(r => r.Id.Equals(installed.Id, StringComparison.OrdinalIgnoreCase));
if (repoPkg != null)
{
var latestRepoVersion = repoPkg.AvailableVersions.OrderByDescending(v => new Version(v)).FirstOrDefault();
if (latestRepoVersion != null && IsNewerVersion(latestRepoVersion, installed.Version))
{
Console.Write($"{installed.Name} ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write($"{installed.Version} ");
Console.ResetColor();
Console.Write("<");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($" {latestRepoVersion}\n");
Console.ResetColor();
//await CheckVulnerabilities(installed.Name, installed.Version);
Console.WriteLine("\tVerfügbare Updates:");
updatesAvailable = true;
string base_url = "https://raw.githubusercontent.com/microsoft/winget-pkgs/refs/heads/master/manifests/";
string firstLetter = repoPkg.Id.Substring(0, 1).ToLower();
string id = repoPkg.Id.Replace(".", "/"); // Main.Sub => Main/Sub
string version = repoPkg.AvailableVersions[0];
string finalURL = base_url + firstLetter + "/" + id + "/" + version + "/" + repoPkg.Id + ".installer.yaml";
string yamlContent = String.Empty;
try
{
yamlContent = await DownloadYamlAsync(finalURL);
} catch(Exception e) {
Console.WriteLine("[error] YAML Manifest konnte nicht heruntergeladen werden");
}
List<(string Architecture, string InstallerUrl)> installerData = ExtractInstallerData(yamlContent);
foreach (var data in installerData)
{
Console.WriteLine($"\t{data.Architecture}: {data.InstallerUrl}");
if(data.Architecture == arch)
{
//await InstallPackageAsync(data.InstallerUrl);
}
}
Console.WriteLine("");
}
else if (latestRepoVersion == null)
{
Console.WriteLine($"[info] Keine Version im Repository für {installed.Name}.");
}
else
{
upToDatePackages.Add($"{installed.Name} {installed.Version} >= {latestRepoVersion}");
}
}
}
Wenn ich das Programm ausführe wird die Zeile
[info] Vergleiche installierte und verfügbare Versionen...
noch angezeigt aber danach kommt eine Fehlermeldung
Unhandled exception. System.FormatException: The input string '50f1' was not in a correct format.
at System.Number.ThrowFormatException[TChar](ReadOnlySpan1 value)
at System.Version.ParseVersion(ReadOnlySpan1 input, Boolean throwOnFailure)
at System.Version.Parse(String input)
at System.Version..ctor(String version)
at Program.<>c.<Main>b__11_4(String v) in C:\Users\thomas\source\repos\Z-Patcher\Z-Patcher\Program.cs:line 212
at System.Linq.CachingComparer2.SetElement(TElement element)
at System.Linq.OrderedEnumerable1.TryGetFirst(Boolean& found)
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found)
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)
at Program.Main(String[] args) in C:\Users\thomas\source\repos\Z-Patcher\Z-Patcher\Program.cs:line 212
at Program.<Main>(String[] args)
Woher kommt der Fehler genau und wie kann ich das fixen?