Try to use
Process Explorer - Sysinternals | Microsoft Learn[
^] tool and find out which process is holding the file. Usually it can be the debugger service which may run under system account. In Process Explorer you can kill process. Or at least reboot in safe mode and delete it.
Another solution is to rename the file which is locked and you will be able to build without problem.
Also you can change output or intermediate paths in project configuration.