views:

68

answers:

3

I have a WinForms utility that I use constantly, and enhance regularly. Roughly one million times, I have hit F5 to compile the utility -- and the compile fails because the utility is running, so the EXE is locked and VS cannot write out the new EXE.

After ~1,000,000 dohs! I'm asking for your help.

If I could run an EXE as the compile begins, I could write KillUtil (picking a name) to kill the utility.

Can it be done? I hit F5, KillUtil executes, and THEN VS compiles?

It would be good if running KillUtil was blocking, i.e. VS would not start the compile until KillUtil completed killing my utility and shut itself down.

TIA, Hoytster

+1  A: 

I assume that you could write a killer application and have it execute in the BeforeBuild target in the project file of your utility. Open the project file in a text editor, remove the comments around the target and add an Exec task. Perhaps?

<Target Name="BeforeBuild">
    <Exec Command="killerapp.exe" />
</Target>
Fredrik Mörk
+4  A: 

Have you tried using a pre-build event? Look in the "Build Events" tab of the Project Properties.

John Saunders
It's worth noting that the Build Events tab is not available for VB.NET projects.
Fredrik Mörk
You're right. In a VB project (class library, at any rate), that's on the Compile tab. Almost at the bottom, there's a button for "Build Events"
John Saunders
A: 

Windows XP and Vista apprently has a utility called TaskKill which is a version of the unix KillAll command.

Which as others have said you will want to run as a pre-build command.

Simeon Pilgrim