Add the Pre-build event to the project (based on the accepted answer ):
taskkill /f /fi "imagename eq $(TargetFileName)"
The command used in another answer may lead to an error in cases where the process is not running.
This option uses a filter ( /fi ) that does not "fail" even if there are 0 matches.
tpower
source share