Skip to content

Commit 518c3d3

Browse files
emafrolfbjarne
authored andcommitted
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 b97b1cf commit 518c3d3

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
@@ -1017,7 +1017,7 @@
10171017
<_ExistingLinkerItemFiles Include="@(_LinkerItemFiles)" Condition="Exists('%(Identity)')" />
10181018
</ItemGroup>
10191019

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

@@ -1858,7 +1858,6 @@
18581858
<!-- When we're building a universal app, we need to collect the list of user frameworks we need to run dsymutil on -->
18591859
<Target Name="_CollectRidSpecificUserFrameworksWithoutDebugSymbols">
18601860
<ReadItemsFromFile
1861-
SessionId="$(BuildSessionId)"
18621861
File="%(_RidSpecificUserFrameworksWithoutDebugSymbolsPath.Identity)"
18631862
Condition="Exists('%(_RidSpecificUserFrameworksWithoutDebugSymbolsPath.Identity)')"
18641863
>
@@ -1879,9 +1878,8 @@
18791878

18801879
<!-- Read the stored list of files to sign if we're an outer build of a multi-rid build -->
18811880
<ReadItemsFromFile
1882-
SessionId="$(BuildSessionId)"
18831881
File="%(_RidSpecificCodesignItemsPath.Identity)"
1884-
Condition="@(_RidSpecificCodesignItemsPath->Count()) &gt; 0 And '$(IsMacEnabled)' == 'true'"
1882+
Condition="@(_RidSpecificCodesignItemsPath->Count()) &gt; 0"
18851883
>
18861884
<Output TaskParameter="Items" ItemName="_RidSpecificCodesignItems" />
18871885
</ReadItemsFromFile>
@@ -2189,8 +2187,7 @@
21892187

21902188
<!-- Write a list of files to sign if we're not an outer build of a multi-rid build -->
21912189
<WriteItemsToFile
2192-
SessionId="$(BuildSessionId)"
2193-
Condition="'$(IsMacEnabled)' == 'true' And '$(_CodesignItemsPath)' != ''"
2190+
Condition="'$(_CodesignItemsPath)' != ''"
21942191
Items="@(_CreateDumpExecutableToSign)"
21952192
ItemName="_CodesignItems"
21962193
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
@@ -2502,8 +2502,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
25022502
>
25032503

25042504
<WriteItemsToFile
2505-
Condition="'$(IsMacEnabled)' == 'true'"
2506-
SessionId="$(BuildSessionId)"
25072505
Items="@(_CodesignBundle)"
25082506
ItemName="_CodesignBundle"
25092507
File="$(DeviceSpecificOutputPath)codesign-bundle.items"
@@ -2512,8 +2510,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
25122510
/>
25132511

25142512
<WriteItemsToFile
2515-
Condition="'$(IsMacEnabled)' == 'true'"
2516-
SessionId="$(BuildSessionId)"
25172513
Items="@(_CodesignItems)"
25182514
ItemName="_CodesignItems"
25192515
File="$(DeviceSpecificOutputPath)codesign.items"
@@ -2973,7 +2969,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
29732969
>
29742970

29752971
<WriteItemsToFile
2976-
Condition="'$(IsMacEnabled)' == 'true' And '$(_PostProcessingItemPath)' != ''"
2972+
Condition="'$(_PostProcessingItemPath)' != ''"
29772973
Items="@(_PostProcessingItem)"
29782974
ItemName="_PostProcessingItem"
29792975
File="$(_PostProcessingItemPath)"

0 commit comments

Comments
 (0)