I have a simple WinForms solution in VS 2010. Whenever I build it, output file (bin\\debug\\app.exe) ends up locked, and subsequent builds fail with a message like
\"
It is not a virus issue. It is visual studio 2010 bug. It seems the issue is related to using visual studio gui designer.
The workaround here is to move locked output file into another temporary one in pre-build event. It make sense to generate temporary file name randomly.
del "$(TargetPath).locked.*" /q
if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath).locked.%random%"
exit /B 0
In case of using constant temporary file names you will just postpone locks:
That workaround works exactly once
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
I have also found a solution with 2 temporary files that works exactly 2 times.