Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class CompileEntitlementsTaskBase : Task
get { return true; }
}

PString MergeEntitlementString (PString pstr, MobileProvision profile)
PString MergeEntitlementString (PString pstr, MobileProvision profile, bool expandWildcards)
{
string TeamIdentifierPrefix;
string AppIdentifierPrefix;
Expand Down Expand Up @@ -96,6 +96,25 @@ PString MergeEntitlementString (PString pstr, MobileProvision profile)

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);
}

Expand All @@ -109,7 +128,7 @@ PArray MergeEntitlementArray (PArray array, MobileProvision profile)
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
Expand All @@ -135,7 +154,7 @@ PDictionary MergeEntitlementDictionary (PDictionary dict, MobileProvision profil
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
Expand Down Expand Up @@ -210,7 +229,7 @@ protected virtual PDictionary GetCompiledEntitlements (MobileProvision profile,
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
Expand Down Expand Up @@ -244,7 +263,7 @@ protected virtual PDictionary GetCompiledEntitlements (MobileProvision profile,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void ValidateEntitlement ()
ExecuteTask (task);
var compiled = PDictionary.FromFile (compiledEntitlements);
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 ("applinks:*.xamarin.com", compiled.GetAssociatedDomains ().ToStringArray ().First (), "#4");
Assert.AreEqual ("Z8CSQKJE7R.*", compiled.GetPassBookIdentifiers ().ToStringArray ().First (), "#5");
Expand Down