How to get Visual Studio to complete work before assembling?

I am creating a WinForms application using Visual Studio 2010. Each time I make changes to the code, I have to run the application and check how it works. The problem is that I do this quite often, and as soon as I forget to close the previous instance of the application, the compiler will give the error "The process cannot access the file bin \ Debug ....", and it really annoys me. Does anyone know if it is possible to force Visual Studio to close an executable instance before assembling.

Many thanks.

+8
visual-studio-2010
source share
4 answers

Idea: Take a pre-build step for an executable project that uses Taskkill to kill the process. Find out more about Taskkill here: http://technet.microsoft.com/en-us/library/bb491009.aspx

+5
source share

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.

+15
source share

In addition to Morten's answer:

Use taskkill and then ignore errors .

 taskkill /F /IM "$(TargetFileName)" exit 0 
+5
source share

The following code from another stackexchange answer worked for me.

wmic process where name = 'chromedriver.exe' delete

0
source share

All Articles