PString MergeEntitlementString(PString pstr, MobileProvision profile) { string TeamIdentifierPrefix; string AppIdentifierPrefix; if (string.IsNullOrEmpty(pstr.Value)) { return((PString)pstr.Clone()); } if (profile == null) { if (!warnedTeamIdentifierPrefix && pstr.Value.Contains("$(TeamIdentifierPrefix)")) { Log.LogWarning(null, null, null, Entitlements, 0, 0, 0, 0, "Cannot expand $(TeamIdentifierPrefix) in Entitlements.plist without a provisioning profile."); warnedTeamIdentifierPrefix = true; } if (!warnedAppIdentifierPrefix && pstr.Value.Contains("$(AppIdentifierPrefix)")) { Log.LogWarning(null, null, null, Entitlements, 0, 0, 0, 0, "Cannot expand $(AppIdentifierPrefix) in Entitlements.plist without a provisioning profile."); warnedAppIdentifierPrefix = true; } } if (profile != null && profile.ApplicationIdentifierPrefix.Count > 0) { AppIdentifierPrefix = profile.ApplicationIdentifierPrefix[0] + "."; } else { AppIdentifierPrefix = string.Empty; } if (profile != null && profile.TeamIdentifierPrefix.Count > 0) { TeamIdentifierPrefix = profile.TeamIdentifierPrefix[0] + "."; } else { TeamIdentifierPrefix = AppIdentifierPrefix; } var customTags = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase) { { "TeamIdentifierPrefix", TeamIdentifierPrefix }, { "AppIdentifierPrefix", AppIdentifierPrefix }, { "CFBundleIdentifier", BundleIdentifier }, }; var expanded = StringParserService.Parse(pstr.Value, customTags); return(new PString(expanded)); }
PString MergeEntitlementString(PString pstr, MobileProvision profile, bool expandWildcards) { string TeamIdentifierPrefix; string AppIdentifierPrefix; if (string.IsNullOrEmpty(pstr.Value)) { return((PString)pstr.Clone()); } if (profile == null) { if (!warnedTeamIdentifierPrefix && pstr.Value.Contains("$(TeamIdentifierPrefix)")) { Log.LogWarning(null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0108); warnedTeamIdentifierPrefix = true; } if (!warnedAppIdentifierPrefix && pstr.Value.Contains("$(AppIdentifierPrefix)")) { Log.LogWarning(null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0109); warnedAppIdentifierPrefix = true; } } if (profile != null && profile.ApplicationIdentifierPrefix.Count > 0) { AppIdentifierPrefix = profile.ApplicationIdentifierPrefix[0] + "."; } else { AppIdentifierPrefix = string.Empty; } if (profile != null && profile.TeamIdentifierPrefix.Count > 0) { TeamIdentifierPrefix = profile.TeamIdentifierPrefix[0] + "."; } else { TeamIdentifierPrefix = AppIdentifierPrefix; } var customTags = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase) { { "TeamIdentifierPrefix", TeamIdentifierPrefix }, { "AppIdentifierPrefix", AppIdentifierPrefix }, { "CFBundleIdentifier", BundleIdentifier }, }; 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)); }