For no reason a rebuild of a .NET MVC project created these errors that wouldn’t go away with restarts, cleans, running as administrator, etc:

Error 383 Unable to copy file “..\root\foo\bar\thing\test.thing.xml” to “bar\thing\test.thing.xml”. Access to the path ‘bar\thing\test.thing.xml’ is denied

As detailed here: https://stackoverflow.com/questions/2895898/visual-studio-build-fails-unable-to-copy-exe-file-from-obj-debug-to-bin-debug

The only thing that worked for me was the answer by https://stackoverflow.com/users/2435679/adrian-booth

When I have come across this problem it is to do with the Fact that the project I am trying to build is set as the Startup project in the solution making the .exe in the obj folder locked ( it also appears in your task manager,) right click another project in your solution and choose set startup project. This will release the lock, remove it from task manager and should let you build.

Took me about an hour to find this!

Also, I have found that occasionally I have a File Explorer window open in the build location – this prevents the build from working too in a similar way! Just close the File Explorer window and try again.

Last modified: April 27, 2023

Author

Comments

Write a Reply or Comment

Your email address will not be published.