msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Bug]: in RC1 copy is failing to overwrite on Linux in some cases that previously succeeded

Open danmoseley opened this issue 2 years ago • 6 comments

Issue Description

This was on an internal Mariner deployment. The message is access denied eg

...../dotnet/7.0.401/sdk/7.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(267,5): error MSB3027: Could not copy "obj/Release/net7.0/DOTNET_7_APP.dll" to "/home/site/wwwroot/DOTNET_7_APP.dll". Exceeded retry count of 10. Failed.  [/tmp/8dbb9829ae9e326/DOTNET_7_APP.csproj]

began in 7.0.400 and MSBUILDDISABLEFEATURESFROMVERSION=17.8 is confirmed to make it go away.

Below is @rainersigwald theory

I don't mean to keep the theory a secret. In 17.7, we changed the MSBuild Copy task to delete the destination file before overwriting it, because (when it was a link) we would sometimes write through the link, corrupting a file in (for example) the NuGet cache. I'm wondering if it's the delete that's failing here, when overwriting would be fine. Setting that env var will disable that change (and others, so it's not a go-to-prod solution)

We don't know why the overwrite was working but the delete isn't, and can get traces.

We need to get some fix into RC2. Perhaps reverting the copy task at least for Linux?

Steps to Reproduce

.

Expected Behavior

.

Actual Behavior

.

Analysis

No response

Versions & Configurations

No response

danmoseley avatar Sep 22 '23 01:09 danmoseley

For 8.0.100-RC2, we added an explicit control to opt back into the old behavior MSBUILDCOPYWITHOUTDELETE=1.

Long term I like this proposal from @danmoseley

What about falling back to regular copy if access denied on the delete?

rainersigwald avatar Sep 22 '23 18:09 rainersigwald

Long term I like this proposal from @danmoseley

What about falling back to regular copy if access denied on the delete?

Well, I liked it. But in fact that's what we're already doing

https://github.com/dotnet/msbuild/blob/3847162365a20626dbef16f2b1153dada9c26965/src/Tasks/Copy.cs#L288-L291

Where

https://github.com/dotnet/msbuild/blob/3847162365a20626dbef16f2b1153dada9c26965/src/Shared/FileUtilities.cs#L857-L866

and

https://github.com/dotnet/msbuild/blob/3847162365a20626dbef16f2b1153dada9c26965/src/Shared/ExceptionHandling.cs#L147-L162

So unless there's some other exception being fired here (when I try to overwrite a running app on Windows I get UnauthorizedAccessException) something else is going on.

rainersigwald avatar Sep 22 '23 19:09 rainersigwald

the ticket is blocked by the undergoing release process in the App Services team. Postponed by December.

YuliiaKovalova avatar Nov 01 '23 13:11 YuliiaKovalova

The package with patched msbuild was given to app services. We are waiting for extended logs results.

YuliiaKovalova avatar Dec 18 '23 09:12 YuliiaKovalova

@YuliiaKovalova Please update status of this issue.

rokonec avatar Feb 01 '24 14:02 rokonec

App Service team hasn't gathered logs yet. Without them we can't proceed.

YuliiaKovalova avatar Feb 01 '24 14:02 YuliiaKovalova

We have agreed to close it since the requested info wasn't provided and there is a doable way to workaround the issue. It can be reconsidered after receiving the missed parts.

YuliiaKovalova avatar Feb 26 '24 16:02 YuliiaKovalova