Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure destination deleted if exists before overwriting #32

Closed
KirillOsenkov opened this issue Oct 13, 2023 · 2 comments
Closed

Ensure destination deleted if exists before overwriting #32

KirillOsenkov opened this issue Oct 13, 2023 · 2 comments

Comments

@KirillOsenkov
Copy link
Member

MSBuild Copy task has recently added this important logic:
https://github.com/dotnet/msbuild/blob/c36a54ed3308d1516ffe1a86b9086c42e4ca996f/src/Tasks/Copy.cs#L288-L294

If the Copy task sees that the destination exists, it deletes it before overwriting. This is important, because if the destination is hardlinked to some other file, previously the Copy task used to effectively overwrite all other hardlinked copies of the content, and this caused corruption that's hard to investigate.

Let's ensure the Copy logic in this repo does the same thing (delete the file before overwriting to "unlink" it in case it's a hardlink)

@erikmav
Copy link
Contributor

erikmav commented Oct 23, 2023

I'm explicitly choosing to let the caller decide what delete policy to apply. I fixed this in the Microsoft.Build.CopyOnWrite SDK in the linked PR above.

@erikmav
Copy link
Contributor

erikmav commented Oct 23, 2023

New Microsoft.Build.CopyOnWrite package published.

@erikmav erikmav closed this as completed Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants