DEV Community

HOSSIEN014
HOSSIEN014

Posted on

Error MSB3027 File Locked by Another Process

today when I tried to build my ASP project I got this error
:

used by another process. The file is locked by: "apiAuthentication (14300)" [C:\Users\abdoalhe\Desktop\Asp_test\authTraining\apiAuthentication\ap
iAuthentication.csproj]
C:\Program Files\dotnet\sdk\8.0.201\Microsoft.Common.CurrentVersion.targets(5254,5): error MSB3027: Could not copy "C:\Users\abdoalhe\Desktop\Asp_tes
t\authTraining\apiAuthentication\obj\Debug\net8.0\apphost.exe" to "bin\Debug\net8.0\apiAuthentication.exe". Exceeded retry count of 10. Failed. The f
ile is locked by: "apiAuthentication (14300)" [C:\Users\abdoalhe\Desktop\Asp_test\authTraining\apiAuthentication\apiAuthentication.csproj]
C:\Program Files\dotnet\sdk\8.0.201\Microsoft.Common.CurrentVersion.targets(5254,5): error MSB3021: Unable to copy file "C:\Users\abdoalhe\Desktop\As
p_test\authTraining\apiAuthentication\obj\Debug\net8.0\apphost.exe" to "bin\Debug\net8.0\apiAuthentication.exe". The process cannot access the file '
ile is locked by: "apiAuthentication (14300)" [C:\Users\abdoalhe\Desktop\Asp_test\authTraining\apiAuthentication\apiAuthentication.csproj]
C:\Program Files\dotnet\sdk\8.0.201\Microsoft.Common.CurrentVersion.targets(5254,5): error MSB3021: Unable to copy file "C:\Users\abdoalhe\Desktop\As
p_test\authTraining\apiAuthentication\obj\Debug\net8.0\apphost.exe" to "bin\Debug\net8.0\apiAuthentication.exe". The process cannot access the file '
p_test\authTraining\apiAuthentication\obj\Debug\net8.0\apphost.exe" to "bin\Debug\net8.0\apiAuthentication.exe". The process cannot access the file '
C:\Users\abdoalhe\Desktop\Asp_test\authTraining\apiAuthentication\bin\Debug\net8.0\apiAuthentication.exe' because it is being used by another process
. [C:\Users\abdoalhe\Desktop\Asp_test\authTraining\apiAuthentication\apiAuthentication.csproj]

this error gives us some information :

  • 1- error name is MSB3027
  • 2- The app tries to copy some files but another process locks the files.
  • 3- it's locked by apiAuthentication
  • 4- the process ID for apiAuthentication is 14300 so with this information, we can solve this problem. we can kill the "14300" process.in windows you can use task manager to do that and in Linux you can say "kill 14300".

another way to solve this is manually navigate to the bin\Debug\net8.0\ directory and delete the apiAuthentication.exe file. Then try rebuilding the solution.

Top comments (0)