Skip to content

Commit 8e6fa76

Browse files
committed
Add output parameter to Copy task and condition Touch task based off of it.
1 parent 6dba77a commit 8e6fa76

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ public partial class Copy : Microsoft.Build.Tasks.TaskExtension, Microsoft.Build
194194
{
195195
public Copy() { }
196196
[Microsoft.Build.Framework.OutputAttribute]
197+
public bool CopiedAtLeastOneFile { get { throw null; } }
198+
[Microsoft.Build.Framework.OutputAttribute]
197199
public Microsoft.Build.Framework.ITaskItem[] CopiedFiles { get { throw null; } }
198200
[Microsoft.Build.Framework.OutputAttribute]
199201
public Microsoft.Build.Framework.ITaskItem[] DestinationFiles { get { throw null; } set { } }

ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public partial class Copy : Microsoft.Build.Tasks.TaskExtension, Microsoft.Build
124124
{
125125
public Copy() { }
126126
[Microsoft.Build.Framework.OutputAttribute]
127+
public bool CopiedAtLeastOneFile { get { throw null; } }
128+
[Microsoft.Build.Framework.OutputAttribute]
127129
public Microsoft.Build.Framework.ITaskItem[] CopiedFiles { get { throw null; } }
128130
[Microsoft.Build.Framework.OutputAttribute]
129131
public Microsoft.Build.Framework.ITaskItem[] DestinationFiles { get { throw null; } set { } }

src/Tasks/Copy.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ public Copy()
139139
[Output]
140140
public ITaskItem[] CopiedFiles { get; private set; }
141141

142+
[Output]
143+
public bool CopiedAtLeastOneFile { get; private set; }
144+
142145
/// <summary>
143146
/// Whether to overwrite files in the destination
144147
/// that have the read-only attribute set.
@@ -297,6 +300,7 @@ FileState destinationFileState // The destination file
297300
Log.LogMessage(MessageImportance.Normal, FileComment, sourceFilePath, destinationFilePath);
298301

299302
File.Copy(sourceFileState.Name, destinationFileState.Name, true);
303+
CopiedAtLeastOneFile = true;
300304
}
301305

302306
destinationFileState.Reset();

src/Tasks/Microsoft.Common.CurrentVersion.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4696,6 +4696,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
46964696

46974697
<Output TaskParameter="DestinationFiles" ItemName="FileWritesShareable"/>
46984698
<Output TaskParameter="CopiedFiles" ItemName="ReferencesCopiedInThisBuild"/>
4699+
<Output TaskParameter="CopiedAtLeastOneFile" PropertyName="CopiedAtLeastOneFile"/>
46994700

47004701
</Copy>
47014702

@@ -4705,7 +4706,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
47054706
input to projects that reference this one. -->
47064707
<Touch Files="@(CopyUpToDateMarker)"
47074708
AlwaysCreate="true"
4708-
Condition="'@(ReferencesCopiedInThisBuild)' != ''">
4709+
Condition="'@(ReferencesCopiedInThisBuild)' != '' and '$(CopiedAtLeastOneFile)' == 'true'">
47094710
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
47104711
</Touch>
47114712

0 commit comments

Comments
 (0)