Is it possible to modify the return code (I think it is also called errorlevel
) of a command submitted in the Build events of Visual Studio?
I am running the command taskkill /F /IM MyApp.vshost.exe
and I would like this command to return 0
when it is in fact returning 128
.
Try
taskkill /F /IM MyApp.vshost.exe || exit /b 0
.Redirect all output to a temp file and exit with code 0, in a batch file. This will effectively ignore any errors from
taskkill
:killit.bat:
Now invoke killit.bat in the build event.
Update After hege posted his answer I figured just pasting the code from the batch file into the build event should work as well, since to my understanding build events in VC are always executed on the command line anyway. And indeed
as a build event works as well. The redirection is still required though.
As seen here in the comment of the accepted answer:
Solve "The command "taskkill /F /IM MyApp.vshost.exe" exited with code 128" error
taskkill /F /IM MyApp.vshost.exe /fi "pid gt 0"
taskkill
with filter returns no error.