Skip to content

Commit 6aa3e82

Browse files
rolfbjarneemaf
andauthored
[msbuild] Always run WriteItemsFromFile locally. (#24211)
Always run 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). This means we need to adjust any corresponding ReadItemsFromFile calls accordingly. It also allows us to remove the remoting support in WriteItemsFromFile, but we can't remove remoting support for ReadItemsFromFile, because sometimes we have to read files that aren't written with WriteItemsFromFile (they're written by other tasks), and these files will have been written remotely. --------- Co-authored-by: Emanuel Fernandez Dell'Oca <[email protected]>
1 parent 76d9242 commit 6aa3e82

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,6 @@
19031903
<!-- When we're building a universal app, we need to collect the list of user frameworks we need to run dsymutil on -->
19041904
<Target Name="_CollectRidSpecificUserFrameworksWithoutDebugSymbols">
19051905
<ReadItemsFromFile
1906-
SessionId="$(BuildSessionId)"
19071906
File="%(_RidSpecificUserFrameworksWithoutDebugSymbolsPath.Identity)"
19081907
Condition="Exists('%(_RidSpecificUserFrameworksWithoutDebugSymbolsPath.Identity)')"
19091908
>
@@ -1924,9 +1923,8 @@
19241923

19251924
<!-- Read the stored list of files to sign if we're an outer build of a multi-rid build -->
19261925
<ReadItemsFromFile
1927-
SessionId="$(BuildSessionId)"
19281926
File="%(_RidSpecificCodesignItemsPath.Identity)"
1929-
Condition="@(_RidSpecificCodesignItemsPath->Count()) &gt; 0 And '$(IsMacEnabled)' == 'true'"
1927+
Condition="@(_RidSpecificCodesignItemsPath->Count()) &gt; 0"
19301928
>
19311929
<Output TaskParameter="Items" ItemName="_RidSpecificCodesignItems" />
19321930
</ReadItemsFromFile>
@@ -2236,8 +2234,7 @@
22362234

22372235
<!-- Write a list of files to sign if we're not an outer build of a multi-rid build -->
22382236
<WriteItemsToFile
2239-
SessionId="$(BuildSessionId)"
2240-
Condition="'$(IsMacEnabled)' == 'true' And '$(_CodesignItemsPath)' != ''"
2237+
Condition="'$(_CodesignItemsPath)' != ''"
22412238
Items="@(_CreateDumpExecutableToSign)"
22422239
ItemName="_CodesignItems"
22432240
File="$(_CodesignItemsPath)"

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 ExecuteRemotely ();
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: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
372372

373373
<RemoveDir SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Directories="$(AppBundleDir).mSYM;@(_DebugSymbolDir)" />
374374
<Delete SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Files="$(DeviceSpecificOutputPath)*.bcsymbolmap" />
375-
<Delete SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Files="$(DeviceSpecificOutputPath)postprocessing.items" />
375+
<Delete Files="$(DeviceSpecificOutputPath)postprocessing.items" />
376376
</Target>
377377

378378
<Target Name="_CleanITunesArtwork" Condition="'$(_CanArchive)' == 'true'" DependsOnTargets="_ComputeTargetArchitectures">
@@ -405,9 +405,9 @@ Copyright (C) 2018 Microsoft. All rights reserved.
405405
<_IpaPackageFile Include="$(DeviceSpecificOutputPath)*.ipa" />
406406
</ItemGroup>
407407

408-
<Delete Condition="'$(IsMacEnabled)' == 'true'" Files="$(DeviceSpecificOutputPath)codesign.items" />
409-
<Delete Condition="'$(IsMacEnabled)' == 'true'" Files="$(DeviceSpecificOutputPath)codesign-bundle.items" />
410-
<Delete SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Files="$(DeviceSpecificOutputPath)native-frameworks.items" />
408+
<Delete Files="$(DeviceSpecificOutputPath)codesign.items" />
409+
<Delete Files="$(DeviceSpecificOutputPath)codesign-bundle.items" />
410+
<Delete Files="$(DeviceSpecificOutputPath)native-frameworks.items" />
411411
<Delete SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Files="@(_IpaPackageFile)" />
412412
</Target>
413413

@@ -2528,7 +2528,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
25282528
>
25292529

25302530
<WriteItemsToFile
2531-
Condition="'$(IsMacEnabled)' == 'true'"
25322531
Items="@(_CodesignBundle)"
25332532
ItemName="_CodesignBundle"
25342533
File="$(DeviceSpecificOutputPath)codesign-bundle.items"
@@ -2537,7 +2536,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
25372536
/>
25382537

25392538
<WriteItemsToFile
2540-
Condition="'$(IsMacEnabled)' == 'true'"
25412539
Items="@(_CodesignItems)"
25422540
ItemName="_CodesignItems"
25432541
File="$(DeviceSpecificOutputPath)codesign.items"
@@ -2993,7 +2991,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
29932991
>
29942992

29952993
<WriteItemsToFile
2996-
Condition="'$(IsMacEnabled)' == 'true' And '$(_PostProcessingItemPath)' != ''"
2994+
Condition="'$(_PostProcessingItemPath)' != ''"
29972995
Items="@(_PostProcessingItem)"
29982996
ItemName="_PostProcessingItem"
29992997
File="$(_PostProcessingItemPath)"

0 commit comments

Comments
 (0)