Skip to content

Commit

Permalink
Merge pull request #6846 from AR-May/copycomplete-fix-backport
Browse files Browse the repository at this point in the history
Skip Updating CopyComplete Marker When Not Necessary
  • Loading branch information
rainersigwald committed Sep 21, 2021
2 parents 1bb7376 + f8a13d0 commit 3e40a09
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>16.11.0</VersionPrefix>
<VersionPrefix>16.11.1</VersionPrefix>
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ public Copy() { }
public Microsoft.Build.Framework.ITaskItem[] SourceFiles { get { throw null; } set { } }
public bool UseHardlinksIfPossible { get { throw null; } set { } }
public bool UseSymboliclinksIfPossible { get { throw null; } set { } }
[Microsoft.Build.Framework.OutputAttribute]
public bool WroteAtLeastOneFile { get { throw null; } }
public void Cancel() { }
public override bool Execute() { throw null; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public Copy() { }
public Microsoft.Build.Framework.ITaskItem[] SourceFiles { get { throw null; } set { } }
public bool UseHardlinksIfPossible { get { throw null; } set { } }
public bool UseSymboliclinksIfPossible { get { throw null; } set { } }
[Microsoft.Build.Framework.OutputAttribute]
public bool WroteAtLeastOneFile { get { throw null; } }
public void Cancel() { }
public override bool Execute() { throw null; }
}
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 WroteAtLeastOneFile { get; private set; }

/// <summary>
/// Whether to overwrite files in the destination
/// that have the read-only attribute set.
Expand Down Expand Up @@ -298,6 +301,9 @@ FileState destinationFileState // The destination file

File.Copy(sourceFileState.Name, destinationFileState.Name, true);
}

// Files were successfully copied or linked. Those are equivalent here.
WroteAtLeastOneFile = 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 @@ -4690,6 +4690,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.

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

</Copy>

Expand All @@ -4699,7 +4700,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 '$(WroteAtLeastOneFile)' == 'true'">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>

Expand Down

0 comments on commit 3e40a09

Please sign in to comment.