Skip to content

Commit 16d5cd2

Browse files
committed
Always run ReadItemsFromFile and WriteItemsFromFile locally
As these operations just read/write items from/to an XML file, this is something we don't need to run remotely when building from Windows. This improves the build performance and also fixes some inconsistencies we had were sometimes files were written locally and read remotely (or the other way around).
1 parent 2da5ab5 commit 16d5cd2

File tree

4 files changed

+6
-35
lines changed

4 files changed

+6
-35
lines changed

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@
10181018
<_ExistingLinkerItemFiles Include="@(_LinkerItemFiles)" Condition="Exists('%(Identity)')" />
10191019
</ItemGroup>
10201020

1021-
<ReadItemsFromFile SessionId="$(BuildSessionId)" File="@(_ExistingLinkerItemFiles)" Condition="'@(_ExistingLinkerItemFiles)' != ''">
1021+
<ReadItemsFromFile File="@(_ExistingLinkerItemFiles)" Condition="'@(_ExistingLinkerItemFiles)' != ''">
10221022
<Output TaskParameter="Items" ItemName="_AllLinkerItems" />
10231023
</ReadItemsFromFile>
10241024

@@ -1868,7 +1868,6 @@
18681868
<!-- When we're building a universal app, we need to collect the list of user frameworks we need to run dsymutil on -->
18691869
<Target Name="_CollectRidSpecificUserFrameworksWithoutDebugSymbols">
18701870
<ReadItemsFromFile
1871-
SessionId="$(BuildSessionId)"
18721871
File="%(_RidSpecificUserFrameworksWithoutDebugSymbolsPath.Identity)"
18731872
Condition="Exists('%(_RidSpecificUserFrameworksWithoutDebugSymbolsPath.Identity)')"
18741873
>
@@ -1889,9 +1888,8 @@
18891888

18901889
<!-- Read the stored list of files to sign if we're an outer build of a multi-rid build -->
18911890
<ReadItemsFromFile
1892-
SessionId="$(BuildSessionId)"
18931891
File="%(_RidSpecificCodesignItemsPath.Identity)"
1894-
Condition="@(_RidSpecificCodesignItemsPath->Count()) &gt; 0 And '$(IsMacEnabled)' == 'true'"
1892+
Condition="@(_RidSpecificCodesignItemsPath->Count()) &gt; 0"
18951893
>
18961894
<Output TaskParameter="Items" ItemName="_RidSpecificCodesignItems" />
18971895
</ReadItemsFromFile>
@@ -2201,8 +2199,7 @@
22012199

22022200
<!-- Write a list of files to sign if we're not an outer build of a multi-rid build -->
22032201
<WriteItemsToFile
2204-
SessionId="$(BuildSessionId)"
2205-
Condition="'$(IsMacEnabled)' == 'true' And '$(_CodesignItemsPath)' != ''"
2202+
Condition="'$(_CodesignItemsPath)' != ''"
22062203
Items="@(_CreateDumpExecutableToSign)"
22072204
ItemName="_CodesignItems"
22082205
File="$(_CodesignItemsPath)"

msbuild/Xamarin.MacDev.Tasks/Tasks/ReadItemsFromFile.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
using Microsoft.Build.Tasks;
99
using System.Xml.Linq;
1010

11-
using Xamarin.Messaging.Build.Client;
12-
1311
namespace Xamarin.MacDev.Tasks {
14-
public class ReadItemsFromFile : XamarinTask, ITaskCallback {
12+
public class ReadItemsFromFile : XamarinTask {
1513
static readonly XNamespace XmlNs = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003");
1614

1715
static readonly XName ItemGroupElementName = XmlNs + "ItemGroup";
@@ -34,9 +32,6 @@ public class ReadItemsFromFile : XamarinTask, ITaskCallback {
3432

3533
public override bool Execute ()
3634
{
37-
if (ShouldExecuteRemotely ())
38-
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
39-
4035
var result = new List<ITaskItem> ();
4136
foreach (var file in File) {
4237
// XDocument.Load(string) takes a string to a URI, not a file path, so with certain characters that becomes a problem.
@@ -73,11 +68,5 @@ ITaskItem CreateItemFromElement (XElement element, string sourceFile)
7368

7469
return item;
7570
}
76-
77-
public bool ShouldCopyToBuildServer (ITaskItem item) => false;
78-
79-
public bool ShouldCreateOutputFile (ITaskItem item) => false;
80-
81-
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
8271
}
8372
}

msbuild/Xamarin.MacDev.Tasks/Tasks/WriteItemsToFile.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
using Microsoft.Build.Tasks;
99
using System.Xml.Linq;
1010

11-
using Xamarin.Messaging.Build.Client;
12-
1311
namespace Xamarin.MacDev.Tasks {
14-
public class WriteItemsToFile : XamarinTask, ICancelableTask {
12+
public class WriteItemsToFile : XamarinTask {
1513
static readonly XNamespace XmlNs = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003");
1614

1715
static readonly XName ProjectElementName = XmlNs + "Project";
@@ -36,9 +34,6 @@ public class WriteItemsToFile : XamarinTask, ICancelableTask {
3634

3735
public override bool Execute ()
3836
{
39-
if (ShouldExecuteRemotely ())
40-
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
41-
4237
Write (this, File?.ItemSpec, Items, ItemName, Overwrite, IncludeMetadata);
4338
return true;
4439
}
@@ -83,11 +78,5 @@ static IEnumerable<XElement> CreateMetadataFromItem (ITaskItem item, bool includ
8378

8479
return Enumerable.Empty<XElement> ();
8580
}
86-
87-
public void Cancel ()
88-
{
89-
if (ShouldExecuteRemotely ())
90-
BuildConnection.CancelAsync (BuildEngine4).Wait ();
91-
}
9281
}
9382
}

msbuild/Xamarin.Shared/Xamarin.Shared.targets

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,8 +2456,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
24562456
>
24572457

24582458
<WriteItemsToFile
2459-
Condition="'$(IsMacEnabled)' == 'true'"
2460-
SessionId="$(BuildSessionId)"
24612459
Items="@(_CodesignBundle)"
24622460
ItemName="_CodesignBundle"
24632461
File="$(DeviceSpecificOutputPath)codesign-bundle.items"
@@ -2466,8 +2464,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
24662464
/>
24672465

24682466
<WriteItemsToFile
2469-
Condition="'$(IsMacEnabled)' == 'true'"
2470-
SessionId="$(BuildSessionId)"
24712467
Items="@(_CodesignItems)"
24722468
ItemName="_CodesignItems"
24732469
File="$(DeviceSpecificOutputPath)codesign.items"
@@ -2927,7 +2923,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
29272923
>
29282924

29292925
<WriteItemsToFile
2930-
Condition="'$(IsMacEnabled)' == 'true' And '$(_PostProcessingItemPath)' != ''"
2926+
Condition="'$(_PostProcessingItemPath)' != ''"
29312927
Items="@(_PostProcessingItem)"
29322928
ItemName="_PostProcessingItem"
29332929
File="$(_PostProcessingItemPath)"

0 commit comments

Comments
 (0)