It was occurred in dotnet build
on docker (dotnet-sdk-3.1, dist:CentOS 8.1).
Log:
/usr/lib64/dotnet/sdk/3.1.111/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(393,5): error MSB4018: The "CreateAppHost" task failed unexpectedly. [<PathToCsproj>.csproj]
System.IO.IOException: The process cannot access the file '/<PathToCsprojDir>/obj/Debug/netcoreapp3.1/<AssemblyName>' because it is being used by another process. [<PathToCsproj>.csproj]
at System.IO.FileStream.Init(FileMode mode, FileShare share, String originalPath) in /_/src/System.Private.CoreLib/shared/System/IO/FileStream.Unix.cs:line 86 [<PathToCsproj>.csproj]
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) in /_/src/System.Private.CoreLib/shared/System/IO/FileStream.cs:line 244 [<PathToCsproj>.csproj]
at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) in /_/src/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs:line 25 [<PathToCsproj>.csproj]
at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) in /_/src/System.IO.FileSystem/src/System/IO/File.cs:line 77 [<PathToCsproj>.csproj]
at Microsoft.NET.HostModel.AppHost.BinaryUtils.CopyFile(String sourcePath, String destinationPath) [<PathToCsproj>.csproj]
at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom) [<PathToCsproj>.csproj]
at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore() [<PathToCsproj>.csproj]
at Microsoft.NET.Build.Tasks.TaskBase.Execute() [<PathToCsproj>.csproj]
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [<PathToCsproj>.csproj]
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [<PathToCsproj>.csproj]
Solution:
Add CopyRetryCount
environment variable.
After that, it works with warning.
export CopyRetryCount=100
dotnet build --verbosity quiet -c Debug
Acknowledgments:
This answer may be off-topic, but it has similar message.
This question has parameter to solve my problem, that was very helpful. Thank you.