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] Show a slightly better warning message when trying to expand TeamIdentifierPrefix/AppIdentifierPrefix without a provisioning profile. #20751

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,12 @@
</value>
</data>

<data name="W0108" xml:space="preserve">
<value>Cannot expand $(TeamIdentifierPrefix) in Entitlements.plist without a provisioning profile.
</value>
<data name="W0108b" xml:space="preserve">
<value>Cannot expand $(TeamIdentifierPrefix) in Entitlements.plist without a provisioning profile for key '{0}' with value '{1}'.</value>
</data>

<data name="W0109" xml:space="preserve">
<value>Cannot expand $(AppIdentifierPrefix) in Entitlements.plist without a provisioning profile.
</value>
<data name="W0109b" xml:space="preserve">
<value>Cannot expand $(AppIdentifierPrefix) in Entitlements.plist without a provisioning profile for key '{0}' with value '{1}'.</value>
</data>

<data name="W0110" xml:space="preserve">
Expand Down
38 changes: 19 additions & 19 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected string EntitlementBundlePath {
}
}

PString MergeEntitlementString (PString pstr, MobileProvision? profile, bool expandWildcards)
PString MergeEntitlementString (PString pstr, MobileProvision? profile, bool expandWildcards, string? key)
{
string TeamIdentifierPrefix;
string AppIdentifierPrefix;
Expand All @@ -148,12 +148,12 @@ PString MergeEntitlementString (PString pstr, MobileProvision? profile, bool exp

if (profile is null) {
if (!warnedTeamIdentifierPrefix && pstr.Value.Contains ("$(TeamIdentifierPrefix)")) {
Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0108);
Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0108b /* Cannot expand $(TeamIdentifierPrefix) in Entitlements.plist without a provisioning profile for key '{0}' with value '{1}' */, key, pstr.Value);
warnedTeamIdentifierPrefix = true;
}

if (!warnedAppIdentifierPrefix && pstr.Value.Contains ("$(AppIdentifierPrefix)")) {
Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0109);
Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0109b /* Cannot expand $(AppIdentifierPrefix) in Entitlements.plist without a provisioning profile for key '{0}' with value '{1}' */, key, pstr.Value);
warnedAppIdentifierPrefix = true;
}
}
Expand Down Expand Up @@ -198,19 +198,19 @@ PString MergeEntitlementString (PString pstr, MobileProvision? profile, bool exp
return new PString (expanded);
}

PArray? MergeEntitlementArray (PArray array, MobileProvision? profile)
PArray? MergeEntitlementArray (PArray array, MobileProvision? profile, string? key)
{
var result = new PArray ();

foreach (var item in array) {
PObject? value;

if (item is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) item, profile);
value = MergeEntitlementDictionary ((PDictionary) item, profile, key);
else if (item is PString)
value = MergeEntitlementString ((PString) item, profile, false);
value = MergeEntitlementString ((PString) item, profile, false, key);
else if (item is PArray)
value = MergeEntitlementArray ((PArray) item, profile);
value = MergeEntitlementArray ((PArray) item, profile, key);
else
value = item.Clone ();

Expand All @@ -224,19 +224,19 @@ PString MergeEntitlementString (PString pstr, MobileProvision? profile, bool exp
return null;
}

PDictionary MergeEntitlementDictionary (PDictionary dict, MobileProvision? profile)
PDictionary MergeEntitlementDictionary (PDictionary dict, MobileProvision? profile, string? key)
{
var result = new PDictionary ();

foreach (var item in dict) {
PObject? value = item.Value;

if (value is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) value, profile);
value = MergeEntitlementDictionary ((PDictionary) value, profile, item.Key);
else if (value is PString)
value = MergeEntitlementString ((PString) value, profile, false);
value = MergeEntitlementString ((PString) value, profile, false, item.Key);
else if (value is PArray)
value = MergeEntitlementArray ((PArray) value, profile);
value = MergeEntitlementArray ((PArray) value, profile, item.Key);
else
value = value.Clone ();

Expand Down Expand Up @@ -286,7 +286,7 @@ void AddCustomEntitlements (PDictionary dict, MobileProvision? profile)
dict [entitlement] = new PBoolean (booleanValue);
break;
case "string":
dict [entitlement] = MergeEntitlementString (new PString (value), profile, entitlement == ApplicationIdentifierKey);
dict [entitlement] = MergeEntitlementString (new PString (value), profile, entitlement == ApplicationIdentifierKey, entitlement);
break;
case "stringarray":
var arraySeparator = item.GetMetadata ("ArraySeparator");
Expand All @@ -295,7 +295,7 @@ void AddCustomEntitlements (PDictionary dict, MobileProvision? profile)
var arrayContent = value.Split (new string [] { arraySeparator }, StringSplitOptions.None);
var parray = new PArray ();
foreach (var element in arrayContent)
parray.Add (MergeEntitlementString (new PString (element), profile, entitlement == ApplicationIdentifierKey));
parray.Add (MergeEntitlementString (new PString (element), profile, entitlement == ApplicationIdentifierKey, entitlement));
dict [entitlement] = parray;
break;
default:
Expand Down Expand Up @@ -358,11 +358,11 @@ protected virtual PDictionary GetCompiledEntitlements (MobileProvision? profile,
if (key == "com.apple.developer.icloud-container-environment")
value = new PString ("Development");
else if (value is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) value, profile);
value = MergeEntitlementDictionary ((PDictionary) value, profile, key);
else if (value is PString)
value = MergeEntitlementString ((PString) value, profile, item.Key == ApplicationIdentifierKey);
value = MergeEntitlementString ((PString) value, profile, item.Key == ApplicationIdentifierKey, key);
else if (value is PArray)
value = MergeEntitlementArray ((PArray) value, profile);
value = MergeEntitlementArray ((PArray) value, profile, key);
else
value = value.Clone ();

Expand Down Expand Up @@ -393,11 +393,11 @@ protected virtual PDictionary GetCompiledEntitlements (MobileProvision? profile,
}

if (value is PDictionary)
value = MergeEntitlementDictionary ((PDictionary) value, profile);
value = MergeEntitlementDictionary ((PDictionary) value, profile, key);
else if (value is PString)
value = MergeEntitlementString ((PString) value, profile, key == ApplicationIdentifierKey);
value = MergeEntitlementString ((PString) value, profile, key == ApplicationIdentifierKey, key);
else if (value is PArray)
value = MergeEntitlementArray ((PArray) value, profile);
value = MergeEntitlementArray ((PArray) value, profile, key);
else
value = value.Clone ();

Expand Down
Loading