My solution has a bunch of projects one of which is a windows service; I have a prebuild step to stop the service and a postbuild step to restart it (this way the windows se
I know this is an old post, but I recently had this issue as well. I wanted to kill the process that I was building if it was currently running, and found that I could do:
taskkill /f /im $(TargetName).exe 2>nul 1>nul Exit 0
2>nul 1>nul without Exit 0, or vice versa, doesn't seem to work. I have to do both.
Also worth noting this is using Visual Studio Express 2012.
I found the solution when looking into this issue as well on this blog
The 2>nul 1>nul will swallow the stderr and stdout from the command. The EXIT 0 will make sure the build event returns 0.