How to launch executable after installation (exe is delivered by .msm) - wix

I did everything as explained in tutorial, but my executable wasn't launched after product installation completed.
There is a nuance that my executable is delivered with .msm module, so in .wxs file for .msi I do the following to launch application:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product>
<!-- I omit here features and elements which are irrelevant to the question-->
<Feature Id="Configurator" Display="hidden" Level="1">
<MergeRef Id="MergeConfigurator"/>
</Feature>
<UI>
<UIRef Id="WixUI_Minimal"/>
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction"
Value="LaunchConfigurator">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.ExitDlgCheckBoxText)" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>
<Property Id="WixShellExecTarget" Value="[#SystemConfigurator.exe.81c0fa8f-9a8e-49d8-9dc2-ce01ca163146]" />
<CustomAction Id="LaunchConfigurator" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
</Product>
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Merge Id="MergeConfigurator" SourceFile="$(var.MergeModulesPath)\ConfiguratorSetup_$(var.Platform).msm" DiskId="1" Language="1033"/>
</DirectoryRef>
</Fragment>
</Wix>
For the property with Id=WixShellExecTarget I have tried to pass value both with and without GUID (this is Package/#Id of .msm with my executable).
I opened my .msi with Orca and saw the exact ID of my executable (it's SystemConfigurator.exe.81c0fa8f-9a8e-49d8-9dc2-ce01ca163146, that's why I pass this very value).
But what it's wrong?
I logged installation process using /l*v option, and there is a portion from log:
Action 18:47:57: LaunchConfigurator.
Action start 18:47:57: LaunchConfigurator.
MSI (c) (54:68) [18:47:58:106]: Invoking remote custom action. DLL: C:\Users\AAGENO~1\AppData\Local\Temp\MSIB233.tmp, Entrypoint: WixShellExec
MSI (c) (54:08) [18:47:58:106]: Cloaking enabled.
MSI (c) (54:08) [18:47:58:106]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (54:08) [18:47:58:106]: Connected to service for CA interface.
MSI (c) (54!04) [18:47:58:476]: Note: 1: 2715 2: SystemConfigurator.Client.exe.81c0fa8f-9a8e-49d8-9dc2-ce01ca163146
MSI (c) (54!04) [18:47:58:476]: Note: 1: 2715 2: SystemConfigurator.Client.exe.81c0fa8f-9a8e-49d8-9dc2-ce01ca163146
Action ended 18:47:58: LaunchConfigurator. Return value 3.
MSI (c) (54:34) [18:47:58:476]: Note: 1: 2205 2: 3: Error
MSI (c) (54:34) [18:47:58:476]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 2896
DEBUG: Error 2896: Executing action LaunchConfigurator failed.

Error 2715 means that the file key you're using isn't actually in the file table. Assuming it's referring to SystemConfigurator.exe.81c0fa8f-9a8e-49d8-9dc2-ce01ca163146 I would open the MSI file with Orca and see if that is the correct value AND keep in mind that Windows Installer proiperties are case-sensitive so if if it really is upper-case then use upper case. Make sure it really is a dash too, and not an underscore.

Related

WiX toolset - EventSource sets wrong path to EventMessageFile (prepends "#%")

I have WiX 4.0 project. I'm using Util to create Windows EventLog event source. The problem is, the Registry entry to the EventMessageFile gets the path prepended with "#%". Therefore, the EventLog will display errors for events created by this event source.
Code to create the EventSource:
<Include xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR64"/>
<PropertyRef Id="NETFRAMEWORK40CLIENTINSTALLROOTDIR64"/>
<PropertyRef Id="NETFRAMEWORK40CLIENT"/>
<PropertyRef Id="NETFRAMEWORK40FULL"/>
.
.
.
<ComponentGroup Id="EventLog" Directory="INSTALLFOLDER">
<!-- 64 bit -->
<Component Id="CreateEventSource64BitFullNet4" DiskId="1" Guid="{9978592B-3E96-4AAA-B7A6-34B0421FDD02}" Condition="NETFRAMEWORK40FULLINSTALLROOTDIR64 AND VersionNT64">
<CreateFolder/>
<util:EventSource Log="Application" Name="ScholarshipSapQueue" EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR64]EventLogMessages.dll" />
</Component>
<Component Id="CreateEventSource64BitClientNet4" DiskId="1" Guid="{B42622A1-B7C0-48CB-B306-65F3558C6678}" Condition="NETFRAMEWORK40CLIENTINSTALLROOTDIR64 AND NOT NETFRAMEWORK40FULL AND VersionNT64">
<CreateFolder/>
<util:EventSource Log="Application" Name="ScholarshipSapQueue" EventMessageFile="[NETFRAMEWORK40CLIENTINSTALLROOTDIR64]EventLogMessages.dll" />
</Component>
</ComponentGroup>
</Include>
Looking at the log file from installing the MSI, the value of the properties does look correct:
MSI (c) (B4:68) [10:05:27:331]: PROPERTY CHANGE: Adding NETFRAMEWORK40FULLINSTALLROOTDIR64 property. Its value is 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\'.
But the Registry entry is wrong:
MSI (s) (3C:28) [10:05:33:008]: Executing op: ActionStart(Name=WriteRegistryValues,Description=Writing system registry values,Template=Key: [1], Name: [2], Value: [3])
Action 10:05:33: WriteRegistryValues. Writing system registry values
MSI (s) (3C:28) [10:05:33:014]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=13200)
MSI (s) (3C:28) [10:05:33:014]: Executing op: RegOpenKey(Root=-2147483646,Key=SYSTEM\CurrentControlSet\Services\EventLog\Application\ScholarshipSapQueue,,BinaryType=0,,)
MSI (s) (3C:28) [10:05:33:014]: Executing op: RegAddValue(Name=EventMessageFile,Value=##%C:\Windows\Microsoft.NET\Framework64\v4.0.30319\EventLogMessages.dll,)
WriteRegistryValues: Key: \SYSTEM\CurrentControlSet\Services\EventLog\Application\ScholarshipSapQueue, Name: EventMessageFile, Value: ##%C:\Windows\Microsoft.NET\Framework64\v4.0.30319\EventLogMessages.dll
That smells like a WiX v4 bug. Please open an issue at https://github.com/wixtoolset/issues/issues/new/choose.

WiX 2716 error: Couldn't create a random subcomponent name for component

I'm trying to make a Wix installer for a project containing approximately 9k files. It's building fine but when running the installer I get an error during the 'Computing space requirements' step:
…
Action ended 14:31:38: CostInitialize. Return value 1.
MSI (c) (7C:F8) [14:31:38:089]: Doing action: FileCost
MSI (c) (7C:F8) [14:31:38:090]: Note: 1: 2205 2: 3: ActionText
Action 14:31:38: FileCost. Computing space requirements
Action start 14:31:38: FileCost.
MSI (c) (7C:F8) [14:31:38:093]: Note: 1: 2205 2: 3: MsiAssembly
MSI (c) (7C:F8) [14:32:40:728]: Note: 1: 2716 2: id_841c16be109411ec8e165c80b69a0712
MSI (c) (7C:F8) [14:32:40:740]: Note: 1: 2205 2: 3: Error
MSI (c) (7C:F8) [14:32:40:740]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 2716
DEBUG: Error 2716: Couldn't create a random subcomponent name for component 'id_841c16be109411ec8e165c80b69a0712'.
I can guarantee that the ID of each component is unique. I tried to Google for any msi limitations but nothing seems to apply in my case: I have 9k files, msi size is less that 1Gb. I tried splitting components among features so that each feature has less than 1600 components as stated here http://www.msifaq.com/a/1043.htm, but that didn't fix the problem. The error goes away however when I reduce total number of files included to ~8k.
What can be a possible cause of the issue?
Here's the general representation of my wxs file:
<Wix>
<Product>
…
<Directory>
…
</Directory>
<FeatureGroup>
<Feature>
<Component Id="id_84aad4c710ac11ec92ad5c80b69a0712" Guid="84AAD4C8-10AC-11EC-A737-5C80B69A0712" Directory="id_811c471310ac11ec92af5c80b69a0712">
<File Id="id_84aad4c910ac11ec935c5c80b69a0712" Source="$(var.sourceDir)\bin\cache\dir\102.1\a47df368\shadercache\release\69128a2106de710dd07ad20c532a6a4c.v.desc" />
<RegistryValue Root="HKCU" Key="Software\Company\Product" Name="dummyName" Value="dummyValue" Type="string" KeyPath="yes" />
<RemoveFolder Id="id_84aad4ca10ac11ec9b0f5c80b69a0712" Directory="id_811c471310ac11ec92af5c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4cb10ac11eca2605c80b69a0712" Directory="id_811c471410ac11ec989a5c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4cc10ac11ecbb915c80b69a0712" Directory="id_811c471510ac11ec91155c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4cd10ac11ecaf505c80b69a0712" Directory="id_811c471610ac11ecbaa15c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4ce10ac11ec86a15c80b69a0712" Directory="id_811c471710ac11ec9b945c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4cf10ac11ecb6035c80b69a0712" Directory="id_811c471810ac11ec8ca15c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4d010ac11ec98ea5c80b69a0712" Directory="id_8111bfae10ac11ec8b805c80b69a0712" On="both" />
<RemoveFolder Id="id_84aad4d110ac11ec93125c80b69a0712" Directory="INSTALLDIR" On="both" />
</Component>
<Component>
…
</Feature>
<Feature>
…
</FeatureGroup>
</Product>
</Wix>
UPDATE: The problem was solved by removing all the RemoveFolder subcomponents (and moving the installation itself to the ProgramFiles folder). I assume that the total number of RemoveFolder entries was over some limit, although the only limitations mentioned in the doc concern number of components or number of files.
From the MSI help file:
MSI Error: 2716 - Could not create a random subcomponent name for component '[2]'.
May occur if the first 40 characters of two or more component names are identical. Ensure that the first 40 characters of component names are unique to the component.
It does not look like this is the case for your component names, but they are pretty similar. I see 9 identical first characters, perhaps there are further name clashes with more characters involved? Please check.
Perhaps you have file names that have more than 40 identical characters? https://www.advancedinstaller.com/forums/viewtopic.php?t=8213

Why does my MSI prompt for administrator rights?

I'm trying get our MSI working for non-admin users.
I'm using WixUI_Advanced, but I'm still getting an admin prompt even when I select "Install just for you":
Looking at the MSI logs I can see that elevation is required, but I don't know why:
MSI (s) (68:54) [10:45:25:359]: Product not registered: beginning first-time install
MSI (s) (68:54) [10:45:25:359]: PROPERTY CHANGE: Deleting ALLUSERS property. Its current value is '1'.
MSI (s) (68:54) [10:45:25:359]: Product {32799511-D146-40F4-ACA7-5A76E6E38854} is not managed.
MSI (s) (68:54) [10:45:25:359]: Machine policy value 'AlwaysInstallElevated' is 0
MSI (s) (68:54) [10:45:25:359]: User policy value 'AlwaysInstallElevated' is 0
MSI (s) (68:54) [10:45:25:359]: MSI_LUA: Elevation required to install product, will prompt for credentials
Any idea why I'm getting prompted for admin rights?
Edit
I created an empty Wix project, used the WixUI_Advanced UI, and I'm getting the same issue :/
Admin Rights Prompt: In the WiX sample below, elevation will be requested and required for per-machine installation, but not for per-user installation.
Heads-Up: I personally do not like per-user setups. I find them to be borderline anti-patterns in my subjective opinion. It relates to poor serviceability (upgrades, patching, etc...) and a number of other details such as dubious folder redirects and some other "high-astonishment" factors. There are also a number of restrictions summarized nicely by the Advanced Installer guys: Advanced Installer: per-user setup limitations.
WiX Issue 5481: I added an answer, but deleted it. It didn't work properly. I had a look in the WiX Issues database and this is a known issue: https://github.com/wixtoolset/issues/issues/5481. The last comment from NicMay looked interesting. I made a quick mock-up below incorporating his / her suggestions with some modifications.
Disclaimer: The below sample has a number of defects, and is only intended as a "runnable sample". There are issues with MSI validation due to the shortcut quick-solution I used (use the shortcut to see where the file installed, right click and go "Properties"). The "Create New Folder" button in the custom installation dialog also has a bug. I will still post it to see if it helps you:
NB!: Create new WiX project, add reference to WixUIExtension.dll, then follow comments. Run setup and click "Advanced" to select per-user or per-machine install.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--CHANGE #1: Add an UpgradeCode GUID below -->
<Product Id="*" Name="PerUserOrPerMachine" Language="1033" Version="1.0.0.0"
Manufacturer="Hobbit" UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="PerUserOrPerMachine" Level="1" />
<!--CHANGE #2: Here we channel "hacker" NicMay with his / her dialog event tweaks mentioned in the WiX issue 5481 -->
<UI>
<UIRef Id="WixUI_Advanced" />
<Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1" Order="3">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="{}" Order="2">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="WixSetDefaultPerMachineFolder" Order="3">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="WixSetDefaultPerUserFolder" Order="3">WixAppFolder = "WixPerUserFolder"</Publish>
</UI>
<Property Id="ApplicationFolderName" Value="PerUserPerMachine" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<!--CHANGE #3: Add components and files as appropriate -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!--CHANGE #4: Make sure DesktopFolder is defined -->
<Directory Id="DesktopFolder" />
<Directory Id="ProgramFilesFolder">
<!--CHANGE #5: Crucial: Make sure Directory Id is APPLICATIONFOLDER (referenced elsewhere) -->
<Directory Id="APPLICATIONFOLDER" Name="PerUserOrPerMachine">
<Component Feature="ProductFeature" Guid="{5A74A1EE-0AD3-4C48-9E6B-4E4E3712A8BB}">
<!--CHANGE #6: Hard coded path below for simplicity, change path or replace construct -->
<File Source="D:\My Test Files\MyTestApplication.exe">
<Shortcut Id="AppDesktopShortcut" Name="PerUserOrPerMachine" Directory="DesktopFolder" />
</File>
<RegistryValue Root="HKCU" Key="Software\My Company\My Product" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
Links:
WiX Simple Setup Per User Installer (sample per-user setup - should not install directly to user profile folders, but set install to ProgramFiles and then allow MSI to do folder redirection).

Remove folder confusion

Using WiX, I'm replacing a application with a new version.
In the old version, there was a directory which is no longer needed in the new version.
So on install, this should do it:
<Component Id="killDir_" Guid="..." KeyPath="yes">
<RemoveFolder Id="killDir" On="both" />
</Component>
So far so good, this works fine.
But if the folder is already removed, the setup creates it again!
This happens also when using
<util:RemoveFolderEx .../>
I have tried a condition within the <Component> tag:
<Condition>OLD_STUFF_EXISTS</Condition>
along with a DirectorySearch in the Product:
<Property Id="OLD_STUFF_EXISTS">
<DirectorySearch Id='DirSearch' Path="OldDir" Depth='0'>
</DirectorySearch>
</Property>
But that doesn't seem to work.
In the MSI log file, the RemoveFolder seems to be executed:
MSI (s) (A0:4C) [13:44:45:742]: Doing action: RemoveFolders
MSI (s) (A0:4C) [13:44:45:742]: Note: 1: 2205 2: 3: ActionText
Action 13:44:45: RemoveFolders. Removing folders
Action start 13:44:45: RemoveFolders.
Action ended 13:44:45: RemoveFolders. Return value 1.
Some lines down, the istalled creates it again:
MSI (s) (A0:4C) [13:44:45:807]: Executing op: FolderCreate(Folder=C:\...\,Foreign=0,,)
Is there any way to tell the installer NOT to create it again?

How to change RemoveExistingProducts to after InstallFinalize when using WixUI_Advanced?

Here's my scenario:
Using Wix 3.6
Using the WixUI_Advanced dialog set (adds ability able to control individual features during install)
Setting NeverOverwrite="yes" for a web.config component (so that local changes post-install aren't lost)
However, the installer still seems to remove and re-install the web.config file during upgrade.
Best I can tell the WixUI_Advanced dialog set has something like the following configured:
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
</InstallExecuteSequence>
Here are logs snippets from the install:
MSI (s) (74:8C) [18:37:00:959]: Executing op: ActionStart(Name=InstallInitialize,,)
Action 18:37:00: InstallInitialize.
...
Action 18:37:00: ProcessComponents. Updating component registration
...
Action 18:37:00: UnpublishFeatures. Unpublishing Product Features
...
UnpublishFeatures: Feature: ProductFeature
...
UnpublishFeatures: Feature: AdditionalFeature
...
MSI (s) (74:8C) [18:37:00:967]: Executing op: ActionStart(Name=RemoveFiles,Description=Removing files,Template=File: [1], Directory: [9])
Action 18:37:00: RemoveFiles. Removing files
MSI (s) (74:8C) [18:37:00:967]: Executing op: ProgressTotal(Total=2,Type=1,ByteEquivalent=175000)
MSI (s) (74:8C) [18:37:00:967]: Executing op: SetTargetFolder(Folder=C:\Program Files (x86)\MyTestApp\WebApp\)
MSI (s) (74:8C) [18:37:00:967]: Executing op: FileRemove(,FileName=web.config,,ComponentId={B4A12A8F-56A3-4DD1-A0BA-B9C39EB305FD})
RemoveFiles: File: web.config, Directory: C:\Program Files (x86)\MyTestApp\WebApp\
MSI (s) (74:8C) [18:37:00:968]: Verifying accessibility of file: web.config
MSI (s) (74:8C) [18:37:00:969]: Note: 1: 2318 2:
MSI (s) (74:8C) [18:37:00:969]: Note: 1: 2318 2:
MSI (s) (74:8C) [18:37:00:969]: Executing op: FileRemove(,FileName=somefile.txt,,ComponentId={B835CEF5-1A84-4C37-8CB0-BE983BAF73F9})
RemoveFiles: File: somefile.txt, Directory: C:\Program Files (x86)\MyTestApp\WebApp\
MSI (s) (74:8C) [18:37:00:970]: Verifying accessibility of file: somefile.txt
MSI (s) (74:8C) [18:37:00:970]: Note: 1: 2318 2:
MSI (s) (74:8C) [18:37:00:970]: Note: 1: 2318 2:
MSI (s) (74:8C) [18:37:00:971]: Executing op: ActionStart(Name=PublishProduct,Description=Publishing product information,)
Action 18:37:00: PublishProduct. Publishing product information
...
Action 18:37:00: RollbackCleanup. Removing backup files
RollbackCleanup: File: C:\Config.Msi\7cd65c.rbf
RollbackCleanup: File: C:\Config.Msi\7cd65d.rbf
MSI (s) (74:8C) [18:37:00:980]: Note: 1: 2318 2:
MSI (s) (74:8C) [18:37:00:981]: Note: 1: 2318 2:
MSI (s) (74:8C) [18:37:00:981]: No System Restore sequence number for this installation.
MSI (s) (74:8C) [18:37:00:981]: Unlocking Server
MSI (s) (74:8C) [18:37:00:985]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'.
Action ended 18:37:00: InstallFinalize. Return value 1.
Action ended 18:37:00: INSTALL. Return value 1.
As you can see it removes the web.config file after InstallInitialize
When I try to change the wxs file, adding:
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize"/>
</InstallExecuteSequence>
I get:
error LGHT0091: Duplicate symbol 'WixAction:InstallExecuteSequence/RemoveExistingProducts' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique.
Here is the Product.wxs file I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="MyTestInstaller" Language="1033" Version="1.0.9.0" Manufacturer="Acme, Inc" UpgradeCode="6ca3779c-e8ce-42e8-bf81-3166bd96e585">
<Package Id="*" InstallerVersion="301" Compressed="yes" InstallScope="perMachine" Platform="x64" InstallPrivileges="elevated" />
<Upgrade Id="6ca3779c-e8ce-42e8-bf81-3166bd96e585">
<UpgradeVersion Minimum="1.0.9.0" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />
<UpgradeVersion OnlyDetect="no" Minimum="0.0.0.0" IncludeMinimum="yes" Maximum="1.0.9.0" Property="OLDERVERSIONBEINGUPGRADED" IgnoreRemoveFailure="yes">
</UpgradeVersion>
</Upgrade>
<Condition Message="A later version of [ProductName] is already installed.">NOT NEWERVERSIONDETECTED</Condition>
<Media Id="1" Cabinet="myapp.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="MyTestInstaller" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Feature Id="AdditionalFeature" Title="Additional Features" Level="10">
<ComponentGroupRef Id="AdditionalComponents"/>
</Feature>
<Property Id="ApplicationFolderName" Value="MyTestApp"/>
<!-- BEGIN: DISABLE THE Per User Install -->
<Property Id="WixAppFolder" Value="WixPerMachineFolder"/>
<WixVariable Id="WixUISupportPerUser" Value="0" />
<!-- END: DISABLE THE Per User Install -->
<UI>
<UIRef Id="WixUI_Advanced" />
</UI>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="ICS">
<Directory Id="WebApp" Name="WebApp">
<Component Id="WEB.CONFIG" Guid="B4A12A8F-56A3-4DD1-A0BA-B9C39EB305FD" DiskId="1" NeverOverwrite="yes">
<File Id="WEB.CONFIG" Name="web.config" Source="web.config" KeyPath="yes"/>
</Component>
<Component Id="SOMEFILE" DiskId="1" Guid="B835CEF5-1A84-4C37-8CB0-BE983BAF73F9">
<File Id="SOMEFILE" Name="somefile.txt" Source="somefile.txt" KeyPath="yes"/>
<util:XmlConfig Id="WEBCFG_1" File="[WebApp]Web.config" Action="create" Node="element" Name="module" ElementPath="/configuration/autofac/modules" VerifyPath="/configuration/autofac/modules/module[\[]#type='ICS.Automation.JDE.Base.JDEModule, ICS.Automation.JDE.Base'[\]]" Sequence="10" On ="install" />
<util:XmlConfig Id="WEBCFG_2" ElementId="WEBCFG_1" File="[WebApp]Web.config" Name="type" Value="MyDll, MyDll" Sequence="11" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents">
<ComponentRef Id="WEB.CONFIG"/>
</ComponentGroup>
<ComponentGroup Id="AdditionalComponents">
<ComponentRef Id="SOMEFILE"/>
</ComponentGroup>
</Fragment>
</Wix>
How can I change the RemoveExistingProducts to come after InstallFinalize?
Ultimately, I just need this file to never be overwritten.
Thanks!
The MajorUpgrade tag is the preferred way to do the upgrade, and that will sequence RemoveExistingProducts (REP) wherever you specify - that should simplify some of this. There's no reason for the UI to move REP around.
The default for scheduling REP is after InstallValidate, which is basically a uninstall of the old product followed by an install of the upgrade, so it's not so much an update/overwrite of the config file as an uninstall/remove followed by a fresh install.
If the REP is scheduled afterInstallExecute then overwrite rules apply during the upgrade (because the upgrade "overwrites" the existing installed product before it's uninstalled). The web.config file just needs to have the same component id in both the old and new products, and if it has indeed been changed after it was installed then the overwrite rules should mean it won't be overwritten.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370531(v=vs.85).aspx
In other words just use the major upgrade element with afterInstallExecute, have the same component ids in both old and new resources (files etc) and the web.config file shouldn't be overwritten, and you don't need to set neveroverwrite.
In my opinion having REP afterInstallExecute is better than after InstallFinalize because the latter is outside the install transaction, so the upgrade install can succeed, then the REP after InstallFinalize can fail and roll back, leaving both products simultaneously installed. Having REP within the transaction results in a full rollback if the uninstall of the older product fails.