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.
Closing visual studio, reopening, and reloading the most recent solution works around the problem for me. (Visual Studio 2013 Ultimate)
This is the solution I find out
Note: You can re enable this option again with no problems.
The problem occurred to me too.
My scenario was this : Running windows 7 (But might also happened in Windows XP) and while working on a project with WPF User Control I could build all of the times, Until opening the XAML file of the User Control - From there, I've got one build, and then the files are locked.
Also, I've noticed that I was running Visual Studio (Devenv.exe) as Administrator, I've started to run Visual Studio without Administrator privileges and the problem was gone!.
Let me know if it helped you too. Good luck.