Skip to content

Commit bfd87e4

Browse files
authored
[msbuild] Verify Mac Catalyst apps like we verify macOS apps. Fixes #17829. (#17835)
* For Mac Catalyst apps we must verify the code signature like we do it for macOS apps. Fixes #17829. * Enable nullability and fix code accordingly. * Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the code. Submission test is added as well: * xamarin/maccore#2656 * xamarin/SubmissionSamples#51 Fixes #17829.
1 parent 6300a6a commit bfd87e4

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

msbuild/Xamarin.MacDev.Tasks/Tasks/CodesignVerify.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

msbuild/Xamarin.MacDev.Tasks/Tasks/CodesignVerifyTaskBase.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
using Microsoft.Build.Framework;
55

66
using Xamarin.Localization.MSBuild;
7+
using Xamarin.Messaging.Build.Client;
78
using Xamarin.Utils;
89

10+
#nullable enable
11+
912
namespace Xamarin.MacDev.Tasks {
10-
public abstract class CodesignVerifyTaskBase : XamarinToolTask {
13+
public class CodesignVerify : XamarinToolTask {
1114
#region Inputs
1215

1316
[Required]
14-
public string CodesignAllocate { get; set; }
17+
public string CodesignAllocate { get; set; } = string.Empty;
1518

1619
[Required]
17-
public string Resource { get; set; }
20+
public string Resource { get; set; } = string.Empty;
1821

1922
#endregion
2023

@@ -43,9 +46,9 @@ protected override string GenerateCommandLineCommands ()
4346
case ApplePlatform.iOS:
4447
case ApplePlatform.TVOS:
4548
case ApplePlatform.WatchOS:
46-
case ApplePlatform.MacCatalyst:
4749
args.AddQuoted ("-R=anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)");
4850
break;
51+
case ApplePlatform.MacCatalyst:
4952
case ApplePlatform.MacOSX:
5053
args.Add ("--deep");
5154
break;
@@ -66,11 +69,22 @@ protected override void LogEventsFromTextOutput (string singleLine, MessageImpor
6669

6770
public override bool Execute ()
6871
{
72+
if (ShouldExecuteRemotely ())
73+
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
74+
6975
EnvironmentVariables = new string [] {
7076
"CODESIGN_ALLOCATE=" + CodesignAllocate
7177
};
7278

7379
return base.Execute ();
7480
}
81+
82+
public override void Cancel ()
83+
{
84+
if (ShouldExecuteRemotely ())
85+
BuildConnection.CancelAsync (BuildEngine4).Wait ();
86+
87+
base.Cancel ();
88+
}
7589
}
7690
}

msbuild/Xamarin.Shared/Xamarin.Shared.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
19591959
-->
19601960
<Target
19611961
Name="_CodesignVerify"
1962-
Condition="'$(_CodesignAppBundleCondition)' == 'true' And '$(_RequireCodeSigning)' == 'true'"
1962+
Condition="'$(_CodesignAppBundleCondition)' == 'true' And '$(_RequireCodeSigning)' == 'true' And '$(DisableCodesignVerification)' != 'true'"
19631963
DependsOnTargets="_CodesignAppBundle"
19641964
>
19651965
<CodesignVerify

0 commit comments

Comments
 (0)