I realised that I could have spent the last twenty years putting all my tech knowledge online. Well, I didn't, but as they say, the best time to plant trees is 20 years ago, the second best time is now. So here's all the random programming stuff I've come across that might be helpful. Note: this isn't really questions and answers - more just answers from me!

Getting MSBuild Error MSB3021 in Visual Studio

0 votes

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!

asked Mar 15, 2018 by Ralpharama (380 points)

1 Answer

0 votes
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.
answered May 16, 2018 by Ralpharama (380 points)