My blog has moved! Redirecting…

You should be automatically redirected. If not, visit http://www.digitalfugu.com/blog/ and update your bookmarks.

Tuesday, October 02, 2007

Install A .Net Service Via Command Line

I've been working with .Net services for the last year or so and it is often convenient for debugging to be able to install your debug version. For us we have a number of services that interact with each other. So we install the service we aren't working on, but that the one we are working depends on, and debug using the IDE. Since it is a major pain to build an installer every time we want to test, we used the command line utility InstallUtil.exe that comes with the .Net Framework to install and uninstall our services in batch files.

If you've installed .Net in the default location InstallUtil.exe lives in C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe
in the respective framework version directory.

Below is an example batch file.
C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe C:\Dev\Server\SourceCode\bin\Debug\server_service.exe
pause
and to uninstall, use the /u flag
C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe /u C:\Dev\Server\SourceCode\bin\Debug\server_service.exe
pause
Using these batch files we just create short cuts to them and can double click the short cut to install or uninstall. Of course you can install/uninstall more than one service in the batch file.

Be sure to also check out the other flags available for InstallUtil.

No comments: