From a68e315d08db61c9eea00bb824e78e7a0760a66a Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 20 Jun 2025 13:05:31 +0200 Subject: [PATCH 1/2] Improve diagnostics when looking for provisioning profiles valid for a set of certificates. Only show diagnostics if failing to match a provisioning profile to any of the valid certificates (i.e. instead of saying "... might not be applicable ...", do the math to be able to not be vague and say "... is not applicable ..."). --- Xamarin.MacDev/MobileProvisionIndex.cs | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Xamarin.MacDev/MobileProvisionIndex.cs b/Xamarin.MacDev/MobileProvisionIndex.cs index 4e78e70..3a89f6d 100644 --- a/Xamarin.MacDev/MobileProvisionIndex.cs +++ b/Xamarin.MacDev/MobileProvisionIndex.cs @@ -723,28 +723,30 @@ public static IList GetMobileProvisions (MobileProvisionPlatfor continue; } - foreach (var cert in profile.DeveloperCertificates) { - if (!thumbprints.Contains (cert.Thumbprint)) { - failures?.Add ($"The profile '{profile.Name}' might not be applicable because its developer certificate (of {profile.DeveloperCertificates.Count} certificates) {cert.Name}'s thumbprint ({cert.Thumbprint}) is not in the list of accepted thumbprints ({string.Join (", ", thumbprints)})."); - continue; - } - - if (unique) { - int idx; - - if (dictionary.TryGetValue (profile.Name, out idx)) { - if (profile.CreationDate > list [idx].CreationDate) - list [idx] = MobileProvision.LoadFromFile (profile.FileName); + var matchingCerts = profile.DeveloperCertificates.Where (cert => thumbprints.Contains (cert.Thumbprint)).ToArray (); + if (!matchingCerts.Any ()) { + failures?.Add ($"The profile '{profile.Name}' ({profile.ApplicationIdentifier}) is not applicable because none of its developer certificates match the currently available certificates. This provisioning profile has {profile.DeveloperCertificates.Count} certificate(s):"); + foreach (var cert in profile.DeveloperCertificates) + failures?.Add ($" {cert.Name} ({cert.Thumbprint})"); + } else { + foreach (var cert in matchingCerts) { + if (unique) { + int idx; + + if (dictionary.TryGetValue (profile.Name, out idx)) { + if (profile.CreationDate > list [idx].CreationDate) + list [idx] = MobileProvision.LoadFromFile (profile.FileName); + } else { + var provision = MobileProvision.LoadFromFile (profile.FileName); + dictionary.Add (profile.Name, list.Count); + list.Add (provision); + } } else { var provision = MobileProvision.LoadFromFile (profile.FileName); - dictionary.Add (profile.Name, list.Count); list.Add (provision); } - } else { - var provision = MobileProvision.LoadFromFile (profile.FileName); - list.Add (provision); + break; } - break; } } From 661095aef18083db23c92fc93e3e4743c34b4468 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 20 Jun 2025 13:13:27 +0200 Subject: [PATCH 2/2] Simplify --- Xamarin.MacDev/MobileProvisionIndex.cs | 27 ++++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Xamarin.MacDev/MobileProvisionIndex.cs b/Xamarin.MacDev/MobileProvisionIndex.cs index 3a89f6d..91cc48a 100644 --- a/Xamarin.MacDev/MobileProvisionIndex.cs +++ b/Xamarin.MacDev/MobileProvisionIndex.cs @@ -723,29 +723,26 @@ public static IList GetMobileProvisions (MobileProvisionPlatfor continue; } - var matchingCerts = profile.DeveloperCertificates.Where (cert => thumbprints.Contains (cert.Thumbprint)).ToArray (); - if (!matchingCerts.Any ()) { + var anyMatchingCerts = profile.DeveloperCertificates.Any (cert => thumbprints.Contains (cert.Thumbprint)); + if (!anyMatchingCerts) { failures?.Add ($"The profile '{profile.Name}' ({profile.ApplicationIdentifier}) is not applicable because none of its developer certificates match the currently available certificates. This provisioning profile has {profile.DeveloperCertificates.Count} certificate(s):"); foreach (var cert in profile.DeveloperCertificates) failures?.Add ($" {cert.Name} ({cert.Thumbprint})"); } else { - foreach (var cert in matchingCerts) { - if (unique) { - int idx; - - if (dictionary.TryGetValue (profile.Name, out idx)) { - if (profile.CreationDate > list [idx].CreationDate) - list [idx] = MobileProvision.LoadFromFile (profile.FileName); - } else { - var provision = MobileProvision.LoadFromFile (profile.FileName); - dictionary.Add (profile.Name, list.Count); - list.Add (provision); - } + if (unique) { + int idx; + + if (dictionary.TryGetValue (profile.Name, out idx)) { + if (profile.CreationDate > list [idx].CreationDate) + list [idx] = MobileProvision.LoadFromFile (profile.FileName); } else { var provision = MobileProvision.LoadFromFile (profile.FileName); + dictionary.Add (profile.Name, list.Count); list.Add (provision); } - break; + } else { + var provision = MobileProvision.LoadFromFile (profile.FileName); + list.Add (provision); } } }