Skip to content

Conversation

@benvillalobos
Copy link
Member

@benvillalobos benvillalobos commented Jul 21, 2021

Fixes #6576

Context

#6576 revealed that the .copycomplete file marker is updated even when the Copy task in _GetCopyFilesMarkedLocal doesn't actually copy anything. This can mess with incremental builds.

Changes Made

This change adds an output parameter, CopiedAtLeastOneFile to the Copy task that the Touch task is now conditioned off of.

Testing

Tested local builds

Notes

This could also be done by having an ITaskItem[] that contains all files that were actually copied. Then the touch task could check if that item were empty. I opted for the straightforward route since the ITaskItem[] solution isn't needed yet, and this implementation can easily be changed when we do need that.

@benvillalobos
Copy link
Member Author

Much like rainer suggested here, I don't think this fixes some other incremental build problems in CSWinRT, but this was certainly a bug for CopyComplete in the first place.

cc @Scottj1s

Copy link
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

I don't think this is right. First, I imagine things that don't technically move anything around but create links still should have it marked as if something were copied. More importantly, the copy step itself sometimes throws an exception if the file doesn't need to be copied, so CopiedAtLeastOneFile should be set after that.

Copy link
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

@ladipro ladipro left a comment

Choose a reason for hiding this comment

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

This could also be done by having an ITaskItem[] that contains all files that were actually copied.

Why doesn't CopiedFiles work here?

msbuild/src/Tasks/Copy.cs

Lines 136 to 140 in 65e44d9

/// <summary>
/// The subset of files that were successfully copied.
/// </summary>
[Output]
public ITaskItem[] CopiedFiles { get; private set; }

}

// 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.

@ladipro
Copy link
Member

ladipro commented Jul 26, 2021

Why doesn't CopiedFiles work here?

Found an answer in the issue! Wondering if the name of the new parameter shouldn't be more explicit in encoding the difference between it and non-empty CopiedFiles.

@benvillalobos
Copy link
Member Author

@ladipro Any suggestions? I considered ActuallyCopiedAtLeastOneFile but thought that may have been too snarky 😄

@ladipro
Copy link
Member

ladipro commented Jul 26, 2021

Maybe SuccessfullyCopiedAtLeastOneFile?

What exactly is the difference between non-empty CopiedFiles and this new output parameter being true? That should help come up with the best name, I believe.

@Forgind
Copy link
Contributor

Forgind commented Jul 26, 2021

CopiedFiles is nonempty if either it copies files (in which case this is true) or it notices it doesn't have to copy files because it's up-to-date, in which case this would be false.

@ladipro
Copy link
Member

ladipro commented Jul 26, 2021

Thank you, how about UpdatedAtLeastOneFile then? Plus a good comment on the prop.

Copy link
Member

@ladipro ladipro left a comment

Choose a reason for hiding this comment

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

Thank you!

@ladipro ladipro added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Jul 26, 2021
@Forgind
Copy link
Contributor

Forgind commented Jul 26, 2021

ChangedFileContents? UpdatedAtLeastOneFile feels to me like it's specifically overwriting, whereas this could be making a new file where there wasn't one before.

@ladipro
Copy link
Member

ladipro commented Jul 26, 2021

WroteAtLeastOneFile? ChangedFileContents sounds like a prop to hold "contents", i.e. it's not obvious that it's a boolean. But not feeling strongly about it.

@Forgind
Copy link
Contributor

Forgind commented Jul 26, 2021

It isn't a huge deal—better would've been to change CopiedFiles, but that isn't an option. I know I've also been annoyed sometimes when there was too much haggling over names 🙂

Whatever you decide, I'm fine with @benvillalobos

@benvillalobos
Copy link
Member Author

I know I've also been annoyed sometimes when there was too much haggling over names

Yeah it gets particularly haggle-some when its public and therefore shouldn't be changed once it's in. UpdatedAtLeastOneFile makes slightly less sense when creating a new file. WroteAtLeastOneFile makes sense for both creating a link and creating a new file. Going with WroteAtLeastOneFile as the final name.

@ladipro ladipro merged commit 02a3a62 into dotnet:main Jul 27, 2021
AR-May pushed a commit to AR-May/msbuild that referenced this pull request Sep 14, 2021
Fixes #dotnet#6576

### Context
dotnet#6576 revealed that the `.copycomplete` file marker is updated even when the `Copy` task in `_GetCopyFilesMarkedLocal` doesn't _actually_ copy anything. This can mess with incremental builds.

### Changes Made
This change adds an output parameter, `CopiedAtLeastOneFile` to the `Copy` task that the `Touch` task is now conditioned off of.

### Testing
Tested local builds

### Notes
This could also be done by having an ITaskItem[] that contains all files that were actually copied. Then the touch task could check if that item were empty. I opted for the straightforward route since the ITaskItem[] solution isn't needed yet, and this implementation can easily be changed when we do need that.

Co-authored-by: Forgind <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual Studio Fast Up To Date build not working - CopyComplete marker is touched when no files are copied

3 participants