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] Take the CustomEntitlements item group into account in DetectSigningIdentity. #19919

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ protected string ApplicationIdentifierKey {

public string CodesignRequireProvisioningProfile { get; set; }

public ITaskItem [] CustomEntitlements { get; set; } = Array.Empty<ITaskItem> ();

public string Keychain { get; set; }

public string SigningKey { get; set; }
Expand Down Expand Up @@ -177,10 +179,13 @@ public bool RequireProvisioningProfile {
}

bool? hasEntitlements;
bool HasEntitlements {
public bool HasEntitlements {
get {
if (!hasEntitlements.HasValue) {
if (string.IsNullOrEmpty (CodesignEntitlements?.ItemSpec)) {
if (CustomEntitlements.Any ()) {
// If we have custom entitlements, then we have entitlements.
hasEntitlements = true;
} else if (string.IsNullOrEmpty (CodesignEntitlements?.ItemSpec)) {
// If no CodesignEntitlements was specified, we don't have any entitlements
hasEntitlements = false;
} else {
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Condition="'$(IsMacEnabled)' == 'true'"
AppBundleName="$(_AppBundleName)"
BundleIdentifier="$(_BundleIdentifier)"
CustomEntitlements="@(CustomEntitlements)"
Keychain="$(CodesignKeychain)"
RequireCodeSigning="$(_RequireCodeSigning)"
SdkIsSimulator="$(_SdkIsSimulator)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;

Expand Down Expand Up @@ -39,6 +40,7 @@ public void Default ()
Assert.AreEqual ($"{Xamarin.Tests.Configuration.XcodeLocation}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate", task.DetectedCodesignAllocate, "DetectedCodesignAllocate");
Assert.AreEqual ("Any", task.DetectedDistributionType, "DetectedDistributionType");
Assert.IsNull (task.DetectedProvisioningProfile, "DetectedProvisioningProfile");
Assert.IsFalse (task.HasEntitlements, "HasEntitlements");
}

const string EmptyEntitlements1 = @"<?xml version=""1.0"" encoding=""UTF-8""?>
Expand Down Expand Up @@ -132,5 +134,21 @@ public void EmptyEntitlements (EntitlementTestCase testCase)
}
Assert.AreEqual ($"{Xamarin.Tests.Configuration.XcodeLocation}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate", task.DetectedCodesignAllocate, "DetectedCodesignAllocate");
}

[Test]
public void CustomEntitlements ()
{
var dir = Cache.CreateTemporaryDirectory ();
var task = CreateTask (dir);
task.CustomEntitlements = new ITaskItem [] { new TaskItem ("keychain-access-group") };
ExecuteTask (task);

Assert.IsNull (task.DetectedAppId, "DetectedAppId");
Assert.AreEqual ("-", task.DetectedCodeSigningKey, "DetectedCodeSigningKey");
Assert.AreEqual ($"{Xamarin.Tests.Configuration.XcodeLocation}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate", task.DetectedCodesignAllocate, "DetectedCodesignAllocate");
Assert.AreEqual ("Any", task.DetectedDistributionType, "DetectedDistributionType");
Assert.IsNull (task.DetectedProvisioningProfile, "DetectedProvisioningProfile");
Assert.IsTrue (task.HasEntitlements, "HasEntitlements");
}
}
}
Loading