Don't override the service account when upgrading a service using WiX toolset
This is a classic source of truth problem. MSI wants to be the source of truth and doesn't have anything in it's code to account for this scenario. It thinks the service should be LocalSystem and so it wants to fix it. ( This isn't just upgrades ... a repair will do the same thing. )
So, what to do?
Option A:
Bring username /password configuration into the MSI. UI work, credential validation and encryption of the creds persisting it on the machine somewhere so that subsequent transactions can decrypt and reuse the credentials.
Note: Risk. The creds can be reverse engineered.. I got news though... so can windows LSA secrets and Application Pool Identities and such.
Option B:
Use custom actions to create the service. This way you can do logic to not touch the service during subsequent transactions.
Option C:
Put conditional expressions on CreateServices standard action to only apply during first time installation and not major upgrades.
Risk: If you ever change anything else about the service it won't get deployed by an upgrade because it's been bypassed. Also this is for all services in your MSI not just this one.
Option D:
Embrace running as a built in service account and use active directory permissions to grant that computer object rights to whatever it connects to.
Option E:
If the user applies creds after install, then they can simply do it again after upgrade. They can deal with it.
Installation package created with WIX Toolset does not remove program folder + files on uninstallation
Clean Testing: You should try the package on a clean virtual to see if you have a "dirty state" on your main box - from prior experiments. It is not uncommon to find several versions of your package in Add / Remove - potentially with different names. This can happen in several ways, but usually it is because of misconfigured major upgrade settings for one or more test versions. Files are not uninstalled before all "clones" are uninstalled. There can also be other reasons for files remaining after uninstall.
List Installed Packages: You can run this script to get a list of all MSI packages installed on your machine: https://github.com/glytzhkof/all/blob/master/MsiHtmlReport-Mini-V4.vbs
Service Installation: You should not use custom actions to install services when using Windows Installer. Here is an old answer to explain why and a sample of how services are supposed to be installed:
- How to install services with WiX / MSI
- https://github.com/Robs79/How-to-create-a-Windows-Service-MSI-Installer-Using-WiX
Essentially you use the ServiceInstall
and ServiceControl
constructs inside the MSI.
Related Topics
How to Implement Custom Authentication in ASP.NET MVC 5
Correct Way to Get the Coredispatcher in a Windows Store App
The Source File Is Different from When the Module Was Built
Remove the Title Bar in Windows Forms
Entity-Framework Code Is Slow When Using Include() Many Times
How to Add an Ampersand for a Value in a ASP.NET/C# App Config File Value
Do Interfaces Derive from System.Object? C# Spec Says Yes, Eric Says No, Reality Says No
Best Way to Store Encryption Keys in .Net C#
How to Embed My Own Fonts in a Winforms App
When Is Readerwriterlockslim Better Than a Simple Lock
How to Sort Depended Objects by Dependency
Cssrewriteurltransform with or Without Virtual Directory
How to Get Byte Array Properly from an Web API Method in C#
Can a Dbcontext Enforce a Filter Policy
How to Convert a Datetime to the Number of Seconds Since 1970