Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 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 @@ -297,6 +300,12 @@ FileState destinationFileState // The destination file
Log.LogMessage(MessageImportance.Normal, FileComment, sourceFilePath, destinationFilePath);

File.Copy(sourceFileState.Name, destinationFileState.Name, true);
CopiedAtLeastOneFile = true;
}
else
{
// Properly linked files will be considered successfully copied files.
CopiedAtLeastOneFile = true;
}

destinationFileState.Reset();
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