Skip to content

Commit 0f91d82

Browse files
committed
Add checks to tasks instead of targets
1 parent 626bfba commit 0f91d82

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@
856856
<!-- Figure out which frameworks are really dynamic libraries, and only publish those -->
857857
<FilterStaticFrameworks
858858
SessionId="$(BuildSessionId)"
859-
Condition="'$(IsMacEnabled)' == 'true' And '@(_FrameworkToPublish)' != ''"
859+
Condition="'$(IsMacEnabled)' == 'true'"
860860
FrameworkToPublish="@(_FrameworkToPublish)"
861861
>
862862
<Output TaskParameter="FrameworkToPublish" ItemName="_FilteredFrameworkToPublish" />
@@ -873,7 +873,7 @@
873873
874874
-->
875875
<GetFullPaths
876-
Condition="'$(IsMacEnabled)' == 'true' And '@(_FilteredFrameworkToPublish)' != ''"
876+
Condition="'$(IsMacEnabled)' == 'true'"
877877
SessionId="$(BuildSessionId)"
878878
Items="@(_FilteredFrameworkToPublish)"
879879
Metadata="Identity;SourceDirectory"
@@ -2620,7 +2620,6 @@ global using nfloat = global::System.Runtime.InteropServices.NFloat%3B
26202620
26212621
-->
26222622
<GetFileSystemEntries
2623-
Condition="'@(_BindingPackagesFromReferencedAssembliesDirectoriesExists)' != ''"
26242623
SessionId="$(BuildSessionIdIfConnected)"
26252624
DirectoryPath="@(_BindingPackagesFromReferencedAssembliesDirectoriesExists)"
26262625
Pattern="*"

msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,4 +1621,12 @@
16211621
{2} and {3}: the different LogicalName metadata
16221622
</comment>
16231623
</data>
1624+
1625+
<data name="M7159" xml:space="preserve">
1626+
<value>Skipping {0} - {1} is empty.</value>
1627+
<comment>
1628+
{0}: the name of the MSBuild task that's being skipped (Copy, GetFullPaths, FilterStaticFrameworks, etc.).
1629+
{1}: the name of the property that is empty (SourceFiles, Items, FrameworkToPublish, etc.).
1630+
</comment>
1631+
</data>
16241632
</root>

msbuild/Xamarin.MacDev.Tasks/MsBuildTasks/Copy.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
extern alias Microsoft_Build_Tasks_Core;
22

3-
using System;
4-
using System.IO;
53
using System.Linq;
64

75
using Microsoft.Build.Framework;
86

7+
using Xamarin.Localization.MSBuild;
98
using Xamarin.Messaging.Build.Client;
109

1110
namespace Microsoft.Build.Tasks {
1211
public class Copy : Microsoft_Build_Tasks_Core::Microsoft.Build.Tasks.Copy {
1312
public string SessionId { get; set; } = string.Empty;
1413
public override bool Execute ()
1514
{
15+
if (SourceFiles?.Any () != true) {
16+
Log.LogMessage (MessageImportance.Low, MSBStrings.M7159 /* Skipping {0} - {1} is empty. */, nameof(Copy), nameof(SourceFiles));
17+
return true;
18+
}
19+
1620
if (!this.ShouldExecuteRemotely (SessionId))
1721
return base.Execute ();
1822

msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public class FilterStaticFrameworks : XamarinTask, ITaskCallback {
2222

2323
public override bool Execute ()
2424
{
25+
if (FrameworkToPublish?.Any () != true) {
26+
Log.LogMessage (MessageImportance.Low, MSBStrings.M7159 /* Skipping {0} - {1} is empty. */, nameof(FilterStaticFrameworks), nameof(FrameworkToPublish));
27+
return true;
28+
}
29+
2530
if (ShouldExecuteRemotely ())
2631
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
2732

msbuild/Xamarin.MacDev.Tasks/Tasks/GetFileSystemEntries.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public class GetFileSystemEntries : XamarinTask, ICancelableTask, ITaskCallback
4343

4444
public override bool Execute ()
4545
{
46+
if (DirectoryPath?.Any () != true) {
47+
Log.LogMessage (MessageImportance.Low, MSBStrings.M7159 /* Skipping {0} - {1} is empty. */, nameof(GetFileSystemEntries), nameof(DirectoryPath));
48+
return true;
49+
}
50+
4651
if (ShouldExecuteRemotely ())
4752
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
4853

msbuild/Xamarin.MacDev.Tasks/Tasks/GetFullPaths.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.Build.Framework;
77
using Microsoft.Build.Utilities;
88

9-
using Xamarin.MacDev.Tasks;
9+
using Xamarin.Localization.MSBuild;
1010
using Xamarin.Messaging.Build.Client;
1111

1212
#nullable enable
@@ -23,6 +23,11 @@ public class GetFullPaths : XamarinTask, ICancelableTask, ITaskCallback {
2323

2424
public override bool Execute ()
2525
{
26+
if (Items?.Any () != true) {
27+
Log.LogMessage (MessageImportance.Low, MSBStrings.M7159 /* Skipping {0} - {1} is empty. */, nameof(GetFullPaths), nameof(Items));
28+
return true;
29+
}
30+
2631
if (ShouldExecuteRemotely ())
2732
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
2833

msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
306306
destination doesn't exist, the source is newer than the destination, or if the source and
307307
destination differ by file size.
308308
-->
309-
<Copy Condition="'$(IsMacEnabled)' == 'true' And '@(_ResolvedFileToPublishAlways)' != ''"
309+
<Copy Condition="'$(IsMacEnabled)' == 'true'"
310310
SessionId="$(BuildSessionId)"
311311
SourceFiles = "@(_ResolvedFileToPublishAlways)"
312312
DestinationFiles="@(_ResolvedFileToPublishAlways->'$(PublishDir)%(RelativePath)')"

0 commit comments

Comments
 (0)