Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public partial class Copy : Microsoft.Build.Tasks.TaskExtension, Microsoft.Build
{
public Copy() { }
[Microsoft.Build.Framework.OutputAttribute]
public bool CopiedAtLeastOneFile { get { throw null; } }
[Microsoft.Build.Framework.OutputAttribute]
public Microsoft.Build.Framework.ITaskItem[] CopiedFiles { get { throw null; } }
[Microsoft.Build.Framework.OutputAttribute]
public Microsoft.Build.Framework.ITaskItem[] DestinationFiles { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public partial class Copy : Microsoft.Build.Tasks.TaskExtension, Microsoft.Build
{
public Copy() { }
[Microsoft.Build.Framework.OutputAttribute]
public bool CopiedAtLeastOneFile { get { throw null; } }
[Microsoft.Build.Framework.OutputAttribute]
public Microsoft.Build.Framework.ITaskItem[] CopiedFiles { get { throw null; } }
[Microsoft.Build.Framework.OutputAttribute]
public Microsoft.Build.Framework.ITaskItem[] DestinationFiles { get { throw null; } set { } }
Expand Down
6 changes: 6 additions & 0 deletions src/Tasks/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public Copy()
[Output]
public ITaskItem[] CopiedFiles { get; private set; }

[Output]
public bool CopiedAtLeastOneFile { get; private set; }

/// <summary>
/// Whether to overwrite files in the destination
/// that have the read-only attribute set.
Expand Down Expand Up @@ -299,6 +302,9 @@ FileState destinationFileState // The destination file
File.Copy(sourceFileState.Name, destinationFileState.Name, true);
}

// Files were successfully copied or linked. Those are equivalent here.
CopiedAtLeastOneFile = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super-nit: This line is not indented properly.


destinationFileState.Reset();

// If the destinationFile file exists, then make sure it's read-write.
Expand Down
3 changes: 2 additions & 1 deletion src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4696,6 +4696,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Output TaskParameter="DestinationFiles" ItemName="FileWritesShareable"/>
<Output TaskParameter="CopiedFiles" ItemName="ReferencesCopiedInThisBuild"/>
<Output TaskParameter="CopiedAtLeastOneFile" PropertyName="CopiedAtLeastOneFile"/>

</Copy>

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

Expand Down