:::: MENU ::::

Install and Uninstall Windows Service Using Post Build Events

Just day before  I built a windows service and it was hard time to install and uninstall service using installUtil.exe from the command line every time I build it.  Automating this task makes building and running windows services projects in Visual Studio much more fluent.

Follows are the step helped me out to Install and Uninstall Windows services right from visual studio.

In Visual Studio right click on your windows services project and choose properties from the context menu to open the properties window.
On the compile tab, at the bottom right click the Build Events… button
The Build Events dialog will open
Make sure that “On successful build” is selected in the Run the post-build event drop down list.
In the Post-build events text box enter commands similar to the following:

%WinDir%\Microsoft.NET\Framework\v2.0.50727\installutil /u “$(TargetPath)”

%WinDir%\Microsoft.NET\Framework\v2.0.50727\installutil “$(TargetPath)”

Just make sure when you run first time the uninstall command will fail , also make sure to select proper framework version for your webservice.

Happy Coding !

So, what do you think ?