oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.08k stars 170 forks source link

Uninstall is failing with error - with error "service could not be deleted" #1555

Open dorlep opened 1 month ago

dorlep commented 1 month ago

I am under development stage , below is my code Scenario -

  1. I installed the project 1st time
  2. Then I develop something
  3. then trying to uninstalled 1st time installed project
  4. and getting below error, not able to uninstall

Could you please help me to uninstall?

image

Feature pccwinFeature = new Feature("PCCWindows", "P job worker", "INSTALLDIR");
            WixSharp.File service;
            var project = new ManagedProject("PCCWindows",
                              new InstallDir(installDir,
                                 new Dir("P job worker",
                      service = new WixSharp.File(pccwinFeature, sourceDir + @"\PJobWorkerService.exe"),
                      new Files(pccwinFeature, sourceDir + @"\*.dll"),
                      new Files(pccwinFeature, sourceDir + @"\*.config"),
                      new Files(pccwinFeature, sourceDir + @"\*.xml")
                      ))
                              , new RegValue(pccwinFeature, WixSharp.RegistryHive.LocalMachine, "Software\\PSuite\\P\\PCCWindows", "InstalledDirectory", "[INSTALLDIR]")
                   )
            {
                DigitalSignature = new DigitalSignature
                {
                    PfxFilePath = digitalSignaturePath,
                    Password = "of2TmunCgb2022",
                    Description = "MyProduct",
                    HashAlgorithm = HashAlgorithmType.sha256
                }
            };

            service.ServiceInstaller = new ServiceInstaller
            {
                Name = "[SERVICENAME]",
                StartOn =null,
                StopOn = null,
                RemoveOn = SvcEvent.Uninstall_Wait,
                Account = "[USERNAME]",
                Password = "[PASSWORD]",
            };

            project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889f");
            project.DefaultDeferredProperties += ",SERVICENAME,DATABASE_CONNECTION,PROVIDER_NAME";
            project.UI = WUI.WixUI_ProgressOnly;
            project.AfterInstall += Msi_AfterInstall;
            ValidateAssemblyCompatibility(); 

Thank you in advance.

oleg-shilo commented 1 month ago

Hm... the error message does not show the name of the service. Meanig that most likely when you specified Name = "[SERVICENAME]", that SERVICENAME property was empty.

I am not sure how WiX/MSI or the system behaves in case of service name is empty. I would expect it to nicely fail. But judging from your question it somehow succeeded.

Did you check that the service is installed?