Skip to content
Merged
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
17 changes: 12 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class CompileEntitlements : XamarinTask, ITaskCallback, ICancelableTask {
public string BundleIdentifier { get; set; } = string.Empty;

[Required]
[Output] // this is required to create an output file on Windows. Note: this is a relative path.
public ITaskItem? CompiledEntitlements { get; set; }

public ITaskItem [] CustomEntitlements { get; set; } = Array.Empty<ITaskItem> ();
Expand Down Expand Up @@ -524,16 +525,16 @@ public override bool Execute ()
/* The path to the entitlements must be resolved to the full path, because we might want to reference it from a containing project that just references this project,
* and in that case it becomes a bit complicated to resolve to a full path on disk when building remotely from Windows. Instead just resolve to a full path here,
* and use that from now on. This has to be done from a task, so that we get the full path on the mac when executed remotely from Windows. */
CompiledEntitlements = new TaskItem (Path.GetFullPath (CompiledEntitlements!.ItemSpec));
var compiledEntitlementsFullPath = new TaskItem (Path.GetFullPath (CompiledEntitlements!.ItemSpec));

if (Platform == Utils.ApplePlatform.MacCatalyst) {
EntitlementsInSignature = CompiledEntitlements;
EntitlementsInSignature = compiledEntitlementsFullPath;
} else if (SdkIsSimulator) {
if (compiled.Count > 0) {
EntitlementsInExecutable = CompiledEntitlements;
EntitlementsInExecutable = compiledEntitlementsFullPath;
}
} else {
EntitlementsInSignature = CompiledEntitlements;
EntitlementsInSignature = compiledEntitlementsFullPath;
}

return !Log.HasLoggedErrors;
Expand Down Expand Up @@ -569,7 +570,13 @@ bool SaveArchivedExpandedEntitlements (PDictionary archived)

public bool ShouldCopyToBuildServer (ITaskItem item) => true;

public bool ShouldCreateOutputFile (ITaskItem item) => true;
public bool ShouldCreateOutputFile (ITaskItem item)
{
// EntitlementsInExecutable and EntitlementsInSignature are full paths on macOS,
// which doesn't work correctly when trying to create such output files on Windows.
var isFullPath = item == EntitlementsInExecutable || item == EntitlementsInSignature;
return !isFullPath;
}

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
{
Expand Down