Error repairing setup created in WiX 3.8 - wix

I have created a Web Server setup in WiX (3.8), It gets installed correctly, but when i Repair it, I get an error 'Fatal error during Installation' and the process is rolled back. below is what i see in logs
MSI (s) (F8:C4) [12:39:26:183]: Executing op: CustomActionSchedule(Action=WriteIIS7ConfigChanges,ActionType=11265,Source=BinaryData,Target=**********,CustomActionData=**********)
MSI (s) (F8:F8) [12:39:26:188]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI7B14.tmp, Entrypoint: WriteIIS7ConfigChanges
WriteIIS7ConfigChanges: Error 0x80070002: Site not found for create application
WriteIIS7ConfigChanges: Error 0x80070002: Failed to configure IIS application.
WriteIIS7ConfigChanges: Error 0x80070002: WriteIIS7ConfigChanges Failed.
CustomAction WriteIIS7ConfigChanges returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 12:39:26: InstallFinalize. Return value 3.
Am i missing out something. Any help is appreciated, Thanks in Advance :)

If it's a repair and the site name is missing, chances are that it was entered in a UI dialog in the original install. In a repair there is no UI to re-enter the site name and properties aren't automatically saved. It may be trying to configure a site with no name. The best way to deal with this type of thing in general is to use the WiX remember property pattern on the site name so that it is preserved and is available for a repair. I can't tell if that would be a good thing in this particular case because I don't know if writing the config changes again on top of the existing config changes will work or be handled correctly by the code. A verbose log of the original install should tell you what property names are being used for site names etc.
If you think it's unlikely that the IIS config changes will break and that they won't need repair, you could consider adding "Not Installed" to the condition on the CA so that a repair won't call it.

Related

WiX: Restart manager always schedules restart when IIS has files in use

We have a msi setup built with WiX which installs the files for our application. Among these files is a website built with ASP.Net Core. We don't do any IIS configuration in the msi. Recently I found that when a website is manually created in IIS which uses the website files and the website is active when an upgrade is executed then the restart manager will try to restart/shutdown IIS but it fails with this error message:
Application 'C:\Windows\System32\inetsrv\w3wp.exe' (pid 45896) cannot be restarted - Application SID does not match Conductor SID..
This error message is somewhat confusing as we are running the msi as Administrator so we should have enough permissions to restart the application?
We want to prevent the need to reboot, so I'm trying to add a custom action to stop the website before the restart manager determines if the reboot is needed. I did some searching and found that the custom action should be scheduled before InstallValidate (found here: https://stackoverflow.com/a/3221478).
But even if I scheduled the custom action before InstallValidate I still get the popup that a reboot is required. Scheduling the custom action even earlier (tried to do it before CostInitialize even) makes no difference. From the logs I've taken it seems that the restart manager runs before any custom actions are executed.
So in my logs I find these log messages pretty early on:
Line 111: MSI (c) (78:DC) [10:06:29:463]: PROPERTY CHANGE: Adding MsiSystemRebootPending property. Its value is '1'.
Line 939: MSI (s) (28:5C) [10:06:45:645]: PROPERTY CHANGE: Adding MsiSystemRebootPending property. Its value is '1'.
and a bit later my custom action is executed:
Line 1453: MSI (s) (28:5C) [10:06:50:977]: Doing action: StopInstallationFolderSites
In the log I see the website holding the files in use is shutdown correctly, but still further in the log I see this:
Line 2800: MSI (c) (78:94) [10:06:54:178]: RESTART MANAGER: Session opened.
Line 2801: MSI (s) (28:5C) [10:06:54:257]: Note: 1: 1610
Line 2802: MSI (s) (28:5C) [10:06:54:257]: Transforming table Error.
Line 2804: Tijdens de installatie moeten bestanden of services worden bijgewerkt die niet kunnen worden bijgewerkt als het systeem actief is. Als u wilt doorgaan, dient u de computer opnieuw op te starten om de installatie te voltooien.
Last line is the localized error message which is shown in the installer UI.
So even though my custom action is shutting down the application which has the files in use, I still get the popup to reboot the machine.
Is there a way I can shutdown the website to release the files before the restart manager determines if a restart is needed?
Set MSIRESTARTMANAGERCONTROL= Disable property in Property table.

A type 2 Custom Action is failing to execute on InstallUISequence while it is executed if put on InstallExecuteSequence

I have a Type 2 Custom Action which is executing an executable file with parameters.
I need to execute this CA before InstallWelcome dialog because it is used to collect some information to pre populate a dialog later.
So I sequenced this CA after CostFinalize action in the InstallUISequence but the installer fails to execute it with an error like below.
If I move the CA in the InstallExecuteSequence sequence it is executed as expected. (As explained in a later comment this is not true, it fails also in this sequence).
Does anyone have any idea what might happened?
Maybe useful information: If same executable is used in a Type 18 Custom Action (the executable is installed with the application's binaries) it is executed without problem.
<CustomAction Id='RunEXE' BinaryKey='EditCfg.exe.CA.ID' ExeCommand='[INSTALLFOLDER][SEPARATOR][CONFIG_FILE_NETWORK_LOCATION][SEPARATOR][USER_NAME][SEPARATOR][PASSWORD][SEPARATOR][WIX_UPGRADE_DETECTED][SEPARATOR][CHECKED_RULE][SEPARATOR][CERTIFICATE_LOCATION]' Execute='immediate' Impersonate='no' Return='check' />
<Binary Id='EditCfg.exe.CA.ID' SourceFile='path_to_the_exe_file'/>
MSI (c) (14:04) [15:18:36:452]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1722
Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action RunEXE, location: C:\Users\yyyyy\AppData\Local\Temp\MSIC8A9.tmp, command: param1§param2§param3§§param5§§param7
The 1722 error indicates that the exe returned a non-zero exit code. If this is expected, you can alter the Return attribute to use ignore instead of check. But if it's not expected, you probably need to figure out what that return code indicates, as odds are high that it's some sort of failure.
Here are a couple things that might cause failures:
The exe file may have some dependencies. Putting just the exe in the binary table doesn't carry its dependencies with it, so attempts to load and run the exe may fail, even before it gets to the exe's main code, depending on the kind of dependency.
When executed as a file installed with the product, the file may not exist in the specified location as of the time the custom action executes. During installation, new files do not show up until a deferred/in-script action after InstallFiles (or regular scheduling after InstallExecute); during uninstallation they often disappear by RemoveFiles. Maintenance can be a combination of those. However, a missing exe would likely result in a 1721 error instead of a 1722 error.
Regardless, note that exe custom actions cannot communicate useful data back to the Windows Installer session, so it will be difficult to leverage any data it finds (or creates) in the UI without the help of additional DLL-based actions or system searches. If you also add a DLL-based action, you may find it more friendly to launch the exe from that action (or even fully incorporate what it does into the dll), as you can log better diagnostics than the generic ones you've seen here.

WIX Installer Error: The system cannot open the device or specified file

I have a WIX installer that acts as a content installer for users. It's supposed to install these files in a specific directory. Unfortunately when I run it I get the following error: "The system cannot open the device or specified file." This then gives me error code 2755 after canceling the install (retry does not work).
I've looked through other questions with similar issues, and it does not appear to be an encryption problem on temp, the install folder, or the MSI installer itself - these all appear fine. This also isn't a problem with the C:\Windows\Installer folder being read-only.
I've never had a problem with a WIX installer before. What other things can I try to get this working?
For me the problem solved when the installer run as administrator.
I was seeing all of the following errors when installing my 3.5 GB .msi generated by WiX:
DEBUG: Error 2709: The specified Component name ('cmpF7216C180B7A7119CC61FDB3BD209D5D') not found in Component Table.
DEBUG: Error 2755: Server returned unexpected error 110 attempting to install package D:\...\setup.msi.
The system cannot open the device or specified file
Turning off EmbedCab made them all go away:
<Wix>...
<Product>...
<MediaTemplate EmbedCab="no" />
I unfortunately now have 30 cab files to deal with, but at least the install succeeds.

How can I know when installation is finished?

If I want to install msi on remote computer in quiet mode, an receive a confirmation if the installation completed successfully or did not succeeded.
I have tried to look for a solution in windows installer API but with no luck...
Is there an event or something like that?
I have found 3 options to validate installation.
From the installation log. Need to find "return value 3" - Error value.
The msiexec process will return exit code.
Using Microsoft.Deployment.WindowsInstaller.Dll.

Launch condition in WIX to check advertise mode

I am running my MSI from command prompt with /jm option. I want to add a LaunchCondition in my WIX file to check whether the MSI is triggered with /jm option.
Thanks in advance.
https://wixtoolset.org/documentation/manual/v3/xsd/wix/advertiseexecutesequence.html
Try using the AdvertiseExecuteSequence tag. You can create an error action to prevent any advertised installations from taking place. Just place the error at the beginning of the sequence.
Initialize the error action:
<CustomAction Id="ErrorMessageId" Error="Insert error message here"/>`
Run the error action:
<AdvertiseExecuteSequence>
<Custom Action="ErrorMessageId" Before="CostInitialize"/>
</AdvertiseExecuteSequence>
Every feature can go into advertised state. One easy way would be to edit the .msi, if possible and add the "msidbFeatureAttributesDisallowAdvertise" (8) and maybe the "msidbFeatureAttributesUIDisallowAbsent" (16) attribute to the MSI feature table. (I don't work with WiX so you will find out yourself).
Another way would be to add a custom action who controls if the ADVERTISE property is nonempty and just abort the installation.
Changing the feature action from advertise to install local would be quite tricky but maybe possible.
If you have a path (.msp) there are other ways to protect it from being installed with features in advertised mode.