dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

dotnet publish gets access denied in only in release mode #10371

Open genifycom opened 5 years ago

genifycom commented 5 years ago

Steps to reproduce

dotnet publish works for -c Debug but gets ACCESS DENIED generating DLL for -c Release

Expected behavior

Build would work for either configuration

Actual behavior

-c Debug works but -c Release does not

Environment data

dotnet --info output:

Publish with -c Release fails with: ... publish: C:\Program Files\dotnet\sdk\2.2.105\Microsoft.Common.CurrentVersion.targets(4194,5): error MSB3021: Unable to copy file "obj\Release\netcoreapp2.1\Test.dll" to "bin\Release\netcoreapp2.1\Test.dll". Access to the path 'C:\Dev\Test\bin\Release\netcoreapp2.1\Test.dll' is denied. [C:\Dev\Test\Test.csproj]

Tracing with Process Monitor shows the the same PID for dotnet.exe opens the output DLL and then opens it again and gets ACCESS DENIED

livarcocc commented 5 years ago

I just tried this and could not repro it. Is this just a vanilla project? Do you have any customization?

Is this fully consistent to you?

genifycom commented 5 years ago

So this happens on several developers machines, not just mine. It fails with different files (even with static files that are not being built by the compiler).

Because there are several class libraries, it is difficult to reproduce simply. The problem is it holds up publishing (we have to keep trying to publish until it finally does).

Is there any debugging I can enable to help track this problem?