[msbuild] Re-added wildcard (*) expandsion for application-identifier… (#2182)

* [msbuild] Re-added wildcard (*) expandsion for application-identifier in Entitlements.plist

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=57119

* Fixed unit tests
This commit is contained in:
Jeffrey Stedfast 2017-06-08 14:01:22 -04:00 коммит произвёл GitHub
Родитель 25468bf617
Коммит 2f4e81809c
2 изменённых файлов: 25 добавлений и 6 удалений

Просмотреть файл

@ -58,7 +58,7 @@ namespace Xamarin.MacDev.Tasks
get { return true; } get { return true; }
} }
PString MergeEntitlementString (PString pstr, MobileProvision profile) PString MergeEntitlementString (PString pstr, MobileProvision profile, bool expandWildcards)
{ {
string TeamIdentifierPrefix; string TeamIdentifierPrefix;
string AppIdentifierPrefix; string AppIdentifierPrefix;
@ -96,6 +96,25 @@ namespace Xamarin.MacDev.Tasks
var expanded = StringParserService.Parse (pstr.Value, customTags); 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); return new PString (expanded);
} }
@ -109,7 +128,7 @@ namespace Xamarin.MacDev.Tasks
if (item is PDictionary) if (item is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) item, profile); value = MergeEntitlementDictionary ((PDictionary) item, profile);
else if (item is PString) else if (item is PString)
value = MergeEntitlementString ((PString) item, profile); value = MergeEntitlementString ((PString) item, profile, false);
else if (item is PArray) else if (item is PArray)
value = MergeEntitlementArray ((PArray) item, profile); value = MergeEntitlementArray ((PArray) item, profile);
else else
@ -135,7 +154,7 @@ namespace Xamarin.MacDev.Tasks
if (value is PDictionary) if (value is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) value, profile); value = MergeEntitlementDictionary ((PDictionary) value, profile);
else if (value is PString) else if (value is PString)
value = MergeEntitlementString ((PString) value, profile); value = MergeEntitlementString ((PString) value, profile, false);
else if (value is PArray) else if (value is PArray)
value = MergeEntitlementArray ((PArray) value, profile); value = MergeEntitlementArray ((PArray) value, profile);
else else
@ -210,7 +229,7 @@ namespace Xamarin.MacDev.Tasks
else if (value is PDictionary) else if (value is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) value, profile); value = MergeEntitlementDictionary ((PDictionary) value, profile);
else if (value is PString) else if (value is PString)
value = MergeEntitlementString ((PString) value, profile); value = MergeEntitlementString ((PString) value, profile, item.Key == ApplicationIdentifierKey);
else if (value is PArray) else if (value is PArray)
value = MergeEntitlementArray ((PArray) value, profile); value = MergeEntitlementArray ((PArray) value, profile);
else else
@ -244,7 +263,7 @@ namespace Xamarin.MacDev.Tasks
if (value is PDictionary) if (value is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) value, profile); value = MergeEntitlementDictionary ((PDictionary) value, profile);
else if (value is PString) else if (value is PString)
value = MergeEntitlementString ((PString) value, profile); value = MergeEntitlementString ((PString) value, profile, item.Key == ApplicationIdentifierKey);
else if (value is PArray) else if (value is PArray)
value = MergeEntitlementArray ((PArray) value, profile); value = MergeEntitlementArray ((PArray) value, profile);
else else

Просмотреть файл

@ -51,7 +51,7 @@ namespace Xamarin.iOS.Tasks
ExecuteTask (task); ExecuteTask (task);
var compiled = PDictionary.FromFile (compiledEntitlements); var compiled = PDictionary.FromFile (compiledEntitlements);
Assert.IsTrue (compiled.Get<PBoolean> (EntitlementKeys.GetTaskAllow).Value, "#1"); Assert.IsTrue (compiled.Get<PBoolean> (EntitlementKeys.GetTaskAllow).Value, "#1");
Assert.AreEqual ("32UV7A8CDE.*", compiled.Get<PString> ("application-identifier").Value, "#2"); Assert.AreEqual ("32UV7A8CDE.com.xamarin.MySingleView", compiled.Get<PString> ("application-identifier").Value, "#2");
Assert.AreEqual ("Z8CSQKJE7R", compiled.Get<PString> ("com.apple.developer.team-identifier").Value, "#3"); Assert.AreEqual ("Z8CSQKJE7R", compiled.Get<PString> ("com.apple.developer.team-identifier").Value, "#3");
Assert.AreEqual ("applinks:*.xamarin.com", compiled.GetAssociatedDomains ().ToStringArray ().First (), "#4"); Assert.AreEqual ("applinks:*.xamarin.com", compiled.GetAssociatedDomains ().ToStringArray ().First (), "#4");
Assert.AreEqual ("Z8CSQKJE7R.*", compiled.GetPassBookIdentifiers ().ToStringArray ().First (), "#5"); Assert.AreEqual ("Z8CSQKJE7R.*", compiled.GetPassBookIdentifiers ().ToStringArray ().First (), "#5");