Use Wix# to install Windows Service

Jan 2, 2015 at 4:13 PM
Could someone provide some sample code to show how to install a windows service using Wix#?
Jan 5, 2015 at 5:37 AM
The "Wix# Samples\AllInOne" contains service registration for the steps for the services. Keep in mind that the service is expected to be self-registering one, which is a good practice anyway. To do that you will need to update your service code with the following simple installation routine:
//in the service static Main
if (args.Contains("/i") || args.Contains("-i"))
else if (args.Contains("/u") || args.Contains("-u"))
//note you may ether leave /LogFile= empty or provide the log file name
static public void Install(bool isInstalling)
        string installUtil = Path.Combine(Path.GetDirectoryName(typeof(string).Assembly.Location), "InstallUtil.exe");
        string[] installArgs = new [] { "/LogFile=", Assembly.GetExecutingAssembly().Location };
        if (!isInstalling) 
            installArgs = new [] { "/u", "/LogFile=", Assembly.GetExecutingAssembly().Location };

        AppDomain.CreateDomain()ExecuteAssembly(installUtil, installArgs );
    catch (Exception ex)
Though I have put in my ToDo the built-in install service routine to be used from the custom actions in with the "non-self-registering" services.
Jan 19, 2015 at 6:45 AM
From the Release v1.0.4.0 ( Service installation is a "first class citizen". There are two code samples in the release downloadables.