Is there a way to automatically stop the ASP.NET Development Server (Cassini) whenever I do a build/rebuild in VS2008 (and then obviously have it start again when required)? Maybe there’s some hidden configuration setting somewhere? Or at least some way to do it as a post-build event maybe?
For some background, the issue is that I’m using Spring.NET for dependency injection, etc, but it loads its singletons on Application Start, meaning that if I change any spring related code/configuration I have to stop the Development Server, so that it starts again next debug/run ensuring the Application Start event is triggered again. In other words, even if you change a bunch of code/config & then start debugging again, it doesn’t actually start again, since its already running, so your new code isn’t being used.
So I ended up with a workaround based off Magnus’ answer, but using the following relatively simple macro (why do they force you to use VB for macros? I feel all dirty):
Basically if the debugger is currently running, it will stop it & then kill any processes named “WebDev.WebServer” which should be all the Cassini instances and then starts the debugger again (which will implicitly start Cassini again). I’m using
proc.Kill()because neitherproc.CloseMainWindow()orproc.WaitForExit(1000)seemed to work…Anyway, once you’ve got your macro you can assign it to keyboard shortcuts, or create custom toolbar buttons to run it.