[msbuild] Optimized provisioning profile lookups (#1360)
Fixes the Mac EmbedProvisionProfile task to not load every single provisioning profile from disk in order to find the requested provisioning profile. Drops the need for wrappers around the use of MobileProvisionIndex since it turns out that MobileProvisionIndex.GetMobileProvision() already does the File.Exists() on name + ".mobileprovision" to avoid needing to scan the index of provisioning profiles.
This commit is contained in:
Родитель
c267c5668c
Коммит
13f17660d2
|
@ -24,27 +24,16 @@ namespace Xamarin.Mac.Tasks
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
static MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string uuid)
|
|
||||||
{
|
|
||||||
var extension = MobileProvision.GetFileExtension (platform);
|
|
||||||
var path = Path.Combine (MobileProvision.ProfileDirectory, uuid + extension);
|
|
||||||
|
|
||||||
if (File.Exists (path))
|
|
||||||
return MobileProvision.LoadFromFile (path);
|
|
||||||
|
|
||||||
return MobileProvision.GetAllInstalledProvisions (platform, true).FirstOrDefault (x => x.Uuid == uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Execute ()
|
public override bool Execute ()
|
||||||
{
|
{
|
||||||
Log.LogTaskName ("EmbedProvisionProfile");
|
Log.LogTaskName ("EmbedProvisionProfile");
|
||||||
Log.LogTaskProperty ("AppBundleDir", AppBundleDir);
|
Log.LogTaskProperty ("AppBundleDir", AppBundleDir);
|
||||||
Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile);
|
Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile);
|
||||||
|
|
||||||
var profile = GetMobileProvision (MobileProvisionPlatform.MacOS, ProvisioningProfile);
|
var profile = MobileProvisionIndex.GetMobileProvision (MobileProvisionPlatform.MacOS, ProvisioningProfile);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
Log.LogError ("Could not locate the provisioning profile with a UUID of {0}.", ProvisioningProfile);
|
Log.LogError ("Could not locate the provisioning profile with a Name or UUID of {0}.", ProvisioningProfile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Microsoft.Build.Framework;
|
using Microsoft.Build.Framework;
|
||||||
|
@ -250,15 +249,9 @@ namespace Xamarin.MacDev.Tasks
|
||||||
return archived;
|
return archived;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string uuid)
|
protected virtual MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string name)
|
||||||
{
|
{
|
||||||
var extension = MobileProvision.GetFileExtension (platform);
|
return MobileProvisionIndex.GetMobileProvision (platform, name);
|
||||||
var path = Path.Combine (MobileProvision.ProfileDirectory, uuid + extension);
|
|
||||||
|
|
||||||
if (File.Exists (path))
|
|
||||||
return MobileProvision.LoadFromFile (path);
|
|
||||||
|
|
||||||
return MobileProvision.GetAllInstalledProvisions (platform, true).FirstOrDefault (x => x.Uuid == uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Execute ()
|
public override bool Execute ()
|
||||||
|
@ -281,7 +274,7 @@ namespace Xamarin.MacDev.Tasks
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty (ProvisioningProfile)) {
|
if (!string.IsNullOrEmpty (ProvisioningProfile)) {
|
||||||
if ((profile = GetMobileProvision (Platform, ProvisioningProfile)) == null) {
|
if ((profile = GetMobileProvision (Platform, ProvisioningProfile)) == null) {
|
||||||
Log.LogError ("Could not locate the provisioning profile with a UUID of {0}.", ProvisioningProfile);
|
Log.LogError ("Could not locate the provisioning profile with a Name or UUID of {0}.", ProvisioningProfile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (Platform == MobileProvisionPlatform.iOS) {
|
} else if (Platform == MobileProvisionPlatform.iOS) {
|
||||||
|
|
|
@ -24,24 +24,13 @@ namespace Xamarin.iOS.Tasks
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string name)
|
|
||||||
{
|
|
||||||
var extension = MobileProvision.GetFileExtension (platform);
|
|
||||||
var path = Path.Combine (MobileProvision.ProfileDirectory, name + extension);
|
|
||||||
|
|
||||||
if (File.Exists (path))
|
|
||||||
return MobileProvision.LoadFromFile (path);
|
|
||||||
|
|
||||||
return MobileProvisionIndex.GetMobileProvision (platform, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Execute ()
|
public override bool Execute ()
|
||||||
{
|
{
|
||||||
Log.LogTaskName ("EmbedMobileProvision");
|
Log.LogTaskName ("EmbedMobileProvision");
|
||||||
Log.LogTaskProperty ("AppBundleDir", AppBundleDir);
|
Log.LogTaskProperty ("AppBundleDir", AppBundleDir);
|
||||||
Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile);
|
Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile);
|
||||||
|
|
||||||
var profile = GetMobileProvision (MobileProvisionPlatform.iOS, ProvisioningProfile);
|
var profile = MobileProvisionIndex.GetMobileProvision (MobileProvisionPlatform.iOS, ProvisioningProfile);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
Log.LogError ("Could not locate the provisioning profile with a Name or UUID of {0}.", ProvisioningProfile);
|
Log.LogError ("Could not locate the provisioning profile with a Name or UUID of {0}.", ProvisioningProfile);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче