visual studio 2010 - DEL "%~f0" at end of post-build batch file causes error code 1 -


i'm trying create post-build script in visual studio clean directory build releases to. batch file executes fine , expected behaviour takes place in visual studio message saying "call post-build.bat" exited code 1.

my batch script follows:

@echo off goto :cleanfiles :cleanfiles set direct = %cd% if exist *.pdb (     del *.pdb ) if exist *.vshost.exe.config (     del *.vshost.exe.config ) if exist *.wpf4.xml (     del *.wpf4.xml ) if exist system.windows.interactivity.xml (     del system.windows.interactivity.xml ) if errorlevel 0 goto makedirectories  :makedirectories if exist %direct%lib (     rmdir /s %direct%lib     rmdir /s %direct%config     rmdir /s %direct%output ) mkdir %direct%lib mkdir %direct%config mkdir %direct%output if errorlevel 0 goto movefiles :movefiles move /y %direct%*.dll %direct%lib move /y %direct%*.xml %direct%config move /y %direct%*.xlsx %direct%output if errorlevel 0 goto delbatch :delbatch del "%~f0" 

edit:

it's del command @ bottom of batch file. there way can fix this?

you error because batch process looking next line execute, file gone.

i believe need explictly exit after deleting file. important exit parsed , executed in same block del command.

del "%~f0"&exit 

or

(   del "%~f0"   exit ) 

Comments