Search code examples
windowswindows-servicesbuild-automationnantinstallutil

Install/Uninstall a Windows Service in a build script with NAnt


Does NAnt have the ability to install or uninstall a windows service, using the InstallUtil utility or whatever else?


Solution

  • You can call Nant's exec task to call InstallUtil and can pass parameters to install or uninstall a service easily

     <target name="install-service">
        <exec program="${framework::get-framework-directory('net-2.0')}\InstallUtil.exe">
          <arg value="-i" />
          <arg value="/name=V1" />
          <arg value="C:\Service\SomeService.exe" />      
        </exec>
      </target>