Reputation: 150108
In order to work around the issue IIS Express Blocks VS 2010SP1 Builds I have created a simple batch file
taskkill /IM iisexpress.exe
exit 0
and set that batch file as a pre-build event.
If IIS Express is actually running, it works great. However, if IIS Express is not running the build fails with the following output:
The process "iisexpress.exe" not found.
The command "E:\Software\Util\KillIisExpress.bat" exited with code -1.
If instead of the batch file I use the taskkill command as the pre-build event, the error changes to
The command "taskkill /IM iisexpress.exe" exited with code 128.
How can I modify the batch file so that, no matter what exit code taskkill returns, the batch file returns with an exit code of 0 so that the VS build succeeds?
Upvotes: 3
Views: 1974
Reputation: 78280
You can use
taskkill /FI "IMAGENAME eq iisexpress.exe"
which will output an info message if iisexpress.exe isn't running, but will return 0. You don't need the batch file with this, just add the command as the Pre-Build Event Command Line.
Upvotes: 2