diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileEntitlementsTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileEntitlementsTaskBase.cs index a4e4e63685..953d5973a9 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileEntitlementsTaskBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileEntitlementsTaskBase.cs @@ -58,7 +58,7 @@ namespace Xamarin.MacDev.Tasks get { return true; } } - PString MergeEntitlementString (PString pstr, MobileProvision profile) + PString MergeEntitlementString (PString pstr, MobileProvision profile, bool expandWildcards) { string TeamIdentifierPrefix; string AppIdentifierPrefix; @@ -96,6 +96,25 @@ namespace Xamarin.MacDev.Tasks var expanded = StringParserService.Parse (pstr.Value, customTags); + if (expandWildcards && expanded.IndexOf ('*') != -1) { + int asterisk = expanded.IndexOf ('*'); + string prefix; + + if (expanded.StartsWith (TeamIdentifierPrefix, StringComparison.Ordinal)) + prefix = TeamIdentifierPrefix; + else if (expanded.StartsWith (AppIdentifierPrefix, StringComparison.Ordinal)) + prefix = AppIdentifierPrefix; + else + prefix = string.Empty; + + var baseBundleIdentifier = expanded.Substring (prefix.Length, asterisk - prefix.Length); + + if (!BundleIdentifier.StartsWith (baseBundleIdentifier, StringComparison.Ordinal)) + expanded = expanded.Replace ("*", BundleIdentifier); + else + expanded = prefix + BundleIdentifier; + } + return new PString (expanded); } @@ -109,7 +128,7 @@ namespace Xamarin.MacDev.Tasks if (item is PDictionary) value = MergeEntitlementDictionary ((PDictionary) item, profile); else if (item is PString) - value = MergeEntitlementString ((PString) item, profile); + value = MergeEntitlementString ((PString) item, profile, false); else if (item is PArray) value = MergeEntitlementArray ((PArray) item, profile); else @@ -135,7 +154,7 @@ namespace Xamarin.MacDev.Tasks if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) - value = MergeEntitlementString ((PString) value, profile); + value = MergeEntitlementString ((PString) value, profile, false); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else @@ -210,7 +229,7 @@ namespace Xamarin.MacDev.Tasks else if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) - value = MergeEntitlementString ((PString) value, profile); + value = MergeEntitlementString ((PString) value, profile, item.Key == ApplicationIdentifierKey); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else @@ -244,7 +263,7 @@ namespace Xamarin.MacDev.Tasks if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) - value = MergeEntitlementString ((PString) value, profile); + value = MergeEntitlementString ((PString) value, profile, item.Key == ApplicationIdentifierKey); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs index ca5ee5e98a..debc467c17 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs @@ -51,7 +51,7 @@ namespace Xamarin.iOS.Tasks ExecuteTask (task); var compiled = PDictionary.FromFile (compiledEntitlements); Assert.IsTrue (compiled.Get (EntitlementKeys.GetTaskAllow).Value, "#1"); - Assert.AreEqual ("32UV7A8CDE.*", compiled.Get ("application-identifier").Value, "#2"); + Assert.AreEqual ("32UV7A8CDE.com.xamarin.MySingleView", compiled.Get ("application-identifier").Value, "#2"); Assert.AreEqual ("Z8CSQKJE7R", compiled.Get ("com.apple.developer.team-identifier").Value, "#3"); Assert.AreEqual ("applinks:*.xamarin.com", compiled.GetAssociatedDomains ().ToStringArray ().First (), "#4"); Assert.AreEqual ("Z8CSQKJE7R.*", compiled.GetPassBookIdentifiers ().ToStringArray ().First (), "#5");