Visual Studio locks output file on build

前端 未结 16 1330
一生所求
一生所求 2020-12-02 06:28

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 \"

16条回答
  •  时光取名叫无心
    2020-12-02 06:43

    Had the same issue, but found a solution (thanks to Keyvan Nayyeri):

    But how to solve this? There are various ways based on your project type but one simple solution that I recommend to Visual Studio add-in developers is to add a simple code to their project's build events.

    You can add following lines of code to the pre-build event command line of your project.

    if exist "$(TargetPath).locked" del "$(TargetPath).locked"
    if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
    

提交回复
热议问题