Skip to content
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
19 changes: 14 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CreatePkgInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
Expand All @@ -9,12 +11,13 @@
#nullable enable

namespace Xamarin.MacDev.Tasks {
public class CreatePkgInfo : XamarinTask, ICancelableTask {
public class CreatePkgInfo : XamarinTask, ICancelableTask, ITaskCallback {
static readonly byte [] PkgInfoData = { 0X41, 0X50, 0X50, 0X4C, 0x3f, 0x3f, 0x3f, 0x3f };
#region Inputs

[Required]
public string OutputPath { get; set; } = "";
[Output]
public ITaskItem OutputPath { get; set; } = null!;

#endregion

Expand All @@ -23,10 +26,10 @@ public override bool Execute ()
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;

if (!File.Exists (OutputPath)) {
Directory.CreateDirectory (Path.GetDirectoryName (OutputPath));
if (!File.Exists (OutputPath.ItemSpec)) {
Directory.CreateDirectory (Path.GetDirectoryName (OutputPath.ItemSpec));

using (var stream = File.OpenWrite (OutputPath)) {
using (var stream = File.OpenWrite (OutputPath.ItemSpec)) {
stream.Write (PkgInfoData, 0, PkgInfoData.Length);
}
}
Expand All @@ -39,5 +42,11 @@ public void Cancel ()
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}

public bool ShouldCopyToBuildServer (ITaskItem item) => false;

public bool ShouldCreateOutputFile (ITaskItem item) => true;

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
}
}
2 changes: 1 addition & 1 deletion msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
</PropertyGroup>
</Target>

<Target Name="_CreatePkgInfo" Condition="'$(IsAppExtension)' == 'false'" DependsOnTargets="_ComputePkgInfoPath" Outputs="$(_PkgInfoPath)">
<Target Name="_CreatePkgInfo" Condition="'$(IsAppExtension)' == 'false'" DependsOnTargets="_ComputePkgInfoPath" Inputs="$(_PkgInfoPath)" Outputs="$(_PkgInfoPath)">
<CreatePkgInfo SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" OutputPath="$(_PkgInfoPath)" />
</Target>

Expand Down
Loading