Wix installer create components based on the Parameter passed to msi - wix

I have two Component files one for each application. I am passing a parameter MachineName to the msi.(example: MachineName=A ) I want to copy all the files mentioned in Component1.wxs and create the Directory-A, ApplicationA and AppPoolA.
The below code works partially. but it creates both the AppPool and creates both the directory all the time. How do I prevent the Directory-B and AppPoolB being created when MachineName=A?
Component1.wxs
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Dir-A">
<Component Id="cmp04AF5786493B45809EFC4A5D12FFB07B" Guid="{6B67F4D0-81AE-47D5-9C3E-1119A560FCAE}">
<File Id="fil04AF5786493B45809EFC4A5D12FFB07B" KeyPath="yes" Source="testA.html" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Dir-AFiles">
<ComponentRef Id="cmp04AF5786493B45809EFC4A5D12FFB07B" />
</ComponentGroup>
</Fragment>
</Wix>
Component2.wxs
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Dir-B">
<Component Id="cmpEBBDC1C336C0421C9AFFF92D4F109355" Guid="{7D5AB6CC-A193-4AC2-827E-806077990149}">
<File Id="filEBBDC1C336C0421C9AFFF92D4F109355" KeyPath="yes" Source="testB.html" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Dir-BFiles">
<ComponentRef Id="cmpEBBDC1C336C0421C9AFFF92D4F109355" />
</ComponentGroup>
</Fragment>
</Wix>
In my Product.wxs
<Property Id="MachineName" />
<iis:WebSite Id="TargetWebsite" Description="Default Web Site or 80 port" xmlns="http://schemas.microsoft.com/wix/IIsExtension">
<iis:WebAddress Id="TargetWebsite" IP="*" Port="80" />
</iis:WebSite>
<Feature Id="IISFeature" Title="IIs" Level="1">
<ComponentRef Id="AppPoolComponentA"/>
<ComponentRef Id="AppPoolComponentB"/>
</Feature>
<!--Do this if MachineName = "A"-->
<Feature Id="FeatureA" Title="Feature A" Level="1">
<Condition Level="1"><![CDATA[MachineName = "A"]]></Condition>
<ComponentGroupRef Id="Dir-AFiles" />
<ComponentRef Id="ComponentA"/>
</Feature>
<!--Do this if MachineName = "B"-->
<Feature Id="FeatureB" Title="Feature B" Level="1">
<Condition Level="1"><![CDATA[MachineName = "B"]]></Condition>
<ComponentGroupRef Id="Dir-BFiles" />
<ComponentRef Id="ComponentB"/>
</Feature>
<!--Do this if MachineName = "A"-->
<Component Id="AppPoolComponentA" Guid="{044A3132-C4F4-422A-836B-46BCF172D720}" Directory="TARGETDIR" Permanent="yes">
<iis:WebAppPool Id="AppPoolA" Name="AppPoolA" ManagedRuntimeVersion="4.0" ManagedPipelineMode="integrated"/>
</Component>
<!--Do this if MachineName = "B"-->
<Component Id="AppPoolComponentB" Guid="{D651DF9C-D80D-4F3E-BE7B-DB2BBA9D24C8}" Directory="TARGETDIR" Permanent="yes">
<iis:WebAppPool Id="AppPoolB" Name="AppPoolB" ManagedRuntimeVersion="4.0" ManagedPipelineMode="integrated"/>
</Component>
<Directory Id="TARGETDIR" Name="SourceDir">
<!--Do this if MachineName = "A"-->
<Directory Id="Dir-A" Name="Directory-A">
<Component Id="ComponentA" Guid="{C25BD2E1-9539-45E3-BF9B-B4DD8FB6DB47}">
<Condition><![CDATA[MachineName = "A"]]></Condition>
<iis:WebVirtualDir Id="VD-A" Alias="DirectoryA" Directory="Dir-A" WebSite="TargetWebsite" xmlns="http://schemas.microsoft.com/wix/IIsExtension">
<iis:WebApplication Id="ApplicationA" Name="DirectoryA" WebAppPool="AppPoolA"/>
</iis:WebVirtualDir>
<CreateFolder/>
</Component>
</Directory>
<!--Do this if MachineName = "B"-->
<Directory Id="ConsoleComponentsDir" Name="Directory-B">
<Component Id="ComponentB" Guid="{EA11875E-87A3-41EC-B60F-D8CA2CF2CB59}">
<Condition><![CDATA[MachineName = "B"]]></Condition>
<iis:WebVirtualDir Id=VD-B" Alias="DirectoryB" Directory="ConsoleComponentsDir" WebSite="TargetWebsite" xmlns="http://schemas.microsoft.com/wix/IIsExtension">
<iis:WebApplication Id="ApplicationB" Name="DirectoryB" WebAppPool="AppPoolB"/>
</iis:WebVirtualDir>
<CreateFolder/>
</Component>
</Directory>
</Directory>

Separate the Directory fragment into two pieces, one for the AppA and an other one for the AppB, I would create a Property "APPASELECTED", which will be set when you select the feature that you want to install.
You could even force it from the command line that way

Related

WiX installing unselected features

I'm in the process of using WiX to create an install package with multiple features. It's using the Mondo UI to allow the user to select one or more features to install. The problem I'm having is that it's always installing all features, regardless of what the user selects.
Below is my WXS file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Setup Test 1" Language="1033" Version="1.0.0.0" Manufacturer="dbush" UpgradeCode="MYGUID="yes" InstallScope="perMachine" Comments="testing the installer" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="all" Title="all features" Description="everything" Level="1" Display="expand">
<Feature Id="file1" Title="file1" Description="file1.txt" Level="1">
<ComponentGroupRef Id="file1" />
</Feature>
<Feature Id="file2" Title="file2" Description="file2.txt" Level="10">
<ComponentGroupRef Id="file2" />
</Feature>
<Feature Id="regkey" Title="registry key" Description="registry properties to install" Level="11">
<ComponentGroupRef Id="regkey" />
</Feature>
</Feature>
<Property Id="PROP1" Value="replacement" />
<UIRef Id="WixUI_Mondo" />
<UIRef Id="WixUI_ErrorProgressText" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="setup_test_1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="file1" Directory="INSTALLFOLDER">
<Component Id="file1.txt" Guid="MYGUID">
<File Id="file1.txt" Source="src/file1.txt" />
</Component>
</ComponentGroup>
<ComponentGroup Id="file2" Directory="INSTALLFOLDER">
<Component Id="file2.txt" Guid="MYGUID">
<File Id="file2.txt" Source="src/test2.txt" />
</Component>
</ComponentGroup>
<ComponentGroup Id="regkey" Directory="INSTALLFOLDER">
<Component Id="reg_key_1">
<RegistryValue Root='HKCU' Key='SOFTWARE\setup_test_1\properties'
Name='prop1' Value='[PROP1]'
Type='string' />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
What could be causing this?
I'm using WiX toolset 3.11.2 and Visual Studio 2017.
This was caused by the main Feature element having Id="all". Changing it to some other string such as "everything" allowed for individual features to be installed.
I wasn't able to find any documentation on why an Id with this name is a special case.

WIX copying files harvested by heat, but does not create cab file

Fairly new to Wix. I have a working msi, but instead of a cab file next to the msi file, I am just getting a folder. I have spent several days trying to figure out why it is not putting the files in a cab file but I am completely at a loss.
The msi file performs exactly as I expect, but distributing the msi alongside a folder is less desirable than just the msi.
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="[Name]" Language="1033" Manufacturer="[Manufacturer]" Version="2.0.30"
UpgradeCode="af66ae21-61e4-4926-954d-ee89acf95ab3">
<Package InstallerVersion="200"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [Name] is already installed." />
<MediaTemplate/>
<Feature Id="ProductFeature" Title="[Title]" Level="1">
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentGroupRef Id="WebApp" />
<ComponentGroupRef Id="ControlApp" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="ManufacturerName" Name="[Name]">
<Directory Id="INSTALLLOCATION" Name="[Name]" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="[Name]"/>
<Directory Id="DesktopFolder" Name="Desktop"></Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="844b584d-6d5f-4825-9541-c7caf74892fb">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="[Name]"
Description="[Name]"
Target="[INSTALLLOCATION]MyApp.exe"
WorkingDirectory="INSTALLLOCATION" />
<RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Name]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop" Guid="629d0ac6-8c63-4309-af33-975925584d1f">
<Shortcut Id="ApplicationDesktopShortcut"
Name="[Name]"
Description="[Name]"
Target="[INSTALLLOCATION]MyApp.exe"
WorkingDirectory="INSTALLLOCATION" />
<RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Name]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
Set the Package/#Compressed attribute to yes.

Windows installer XML doesn't copy assemblies into the installer

I have trouble with my installer file. The installer does build without any error but when I try to install it on another computer (which obvious doesn't have have the required assemblies) I am getting an error which says that the assembly couldn't be found. Do I miss something obvious?
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Recap" Language="1033" Version="1.0.0.0" Manufacturer="Lavahayn Technology" UpgradeCode="6824BC1E-B8AD-4EE0-B3F7-B3E84859B9F9">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<WixVariable Id="WixUILicenseRtf" Value="license.rtf" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<Feature Id="ProductFeature" Title="Recap" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ApplicationShortcuts"/>
<ComponentRef Id="UninstallerShortCut" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="Company" Name="Lavahayn Technology" >
<Directory Id="INSTALLFOLDER" Name="Recap" >
<Component Id="UninstallerShortCut" Guid="3AE87174-A4B1-4887-8D23-5CC651B0CED8">
<Shortcut Id="UninstallProduct2"
Name="Uninstall"
Description="Removes Recap from your computer"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]"/>
<RemoveFolder Id="INSTALLFOLDER" On="uninstall"/>
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="Lavahayn Technology">
<Component Id="ApplicationShortcuts" Guid="432BC349-14B9-4224-B226-A0C55B25498A">
<Shortcut Id="RecapShortcut" Name="Recap" Description="Lavahayn Technology Recap"
Target="[INSTALLDIR]LavahaynTechnology.Launcher.exe" WorkingDirectory="INSTALLDIR"/>
<RegistryValue Root="HKCU" Key="Software\LavahaynTechnology\Recap"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<Shortcut Id="UninstallProduct"
Name="Uninstall"
Description="Removes Recap from your computer"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="LavahaynTechnology.CsharpRecap.exe" Guid="1006A341-572D-45D7-9C0E-6F199C1CF0F5">
<File Id="LavahaynTechnology.CsharpRecap.exe" Source="$(var.CsharpRecap.TargetDir)CsharpRecap.exe" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="LavahaynTechnology.Database.dll" Guid="872452AA-7075-450B-A28F-90252E9DBB6F">
<File Id="LavahaynTechnology.Database.dll" Source="$(var.LavahaynTechnology.Database.TargetDir)LavahaynTechnology.Database.dll" KeyPath="yes" Assembly=".net"/>
</Component>
<Component Id="LavahaynTechnology.Launcher.exe" Guid="C0FEB7B4-87BF-4120-A40C-A5849B84F6DA">
<File Id="LavahaynTechnology.Launcher.exe" Source="$(var.LavahaynTechnology.Launcher.TargetDir)LavahaynTechnology.Launcher.exe" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="LavahaynTechnology.SDK.dll" Guid="55A6AEDA-162D-4BB7-9F7E-0BFBCB738402">
<File Id="LavahaynTechnology.SDK.dll" Source="$(var.LavahaynTechnology.SDK.TargetDir)LavahaynTechnology.SDK.dll" KeyPath="yes" Assembly=".net" />
</Component>
<Component Id="LavahaynTechnology.ObjectBase.dll" Guid="259F7357-D000-4B97-BA29-F11A176319CB">
<File Id="LavahaynTechnology.ObjectBase.dll" Source="$(var.LavahaynTechnology.ObjectBase.TargetDir)LavahaynTechnology.ObjectBase.dll" KeyPath="yes" Assembly=".net" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Error Message

WiX Installer does not add Application to Programs and Features

I have a VB.net based WiX installer which seems to function as required in that it copies all the relevent files to the target folders on the machine, however for some reason the installer does not appear to present the application in Programs and Features. I am a relative newbie to WiX and based this WiX Installer project on a previous Windows Service project that I developed, which worked properly. Hoping someone can point out to me where I am going wrong. Code detailed below, please note all registry entries and GUIDs have been hashed-out for security purposes:
<?xml version="1.0" encoding="UTF-8"?>
<?define SourceDir = "..\..\Bin\Debug" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="PSALERTSClient" Language="1033" Version="1.0.0.0" Manufacturer="Iberdrola, S.A." UpgradeCode="a6fd9179-efe6-47d1-bd8f-aec182d36c8b">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="PSALERTS Client" Level="1">
<ComponentRef Id="cmpDirQuery" />
<ComponentRef Id="cmpDirQueryOutput" />
<ComponentRef Id="cmpQueryExe" />
<ComponentRef Id="cmpQueryPdb" />
<ComponentRef Id="cmpBusinessLogicDll" />
<ComponentRef Id="cmpBusinessLogicPdb" />
<ComponentRef Id="cmpBusinessObjectDll" />
<ComponentRef Id="cmpBusinessObjectPdb" />
<ComponentRef Id="cmpCommonDll" />
<ComponentRef Id="cmpCommonPdb" />
<ComponentRef Id="cmpDataAccessDll" />
<ComponentRef Id="cmpDataAccessPdb" />
<ComponentRef Id="cmpDPAPIHelperDll" />
<ComponentRef Id="cmpDPAPIHelperPdb" />
<ComponentRef Id="cmpLoggerDll" />
<ComponentRef Id="cmpLoggerPdb" />
<ComponentRef Id="cmpPSALERTSIni" />
<ComponentRef Id="cmpPSALERTSXltm" />
<ComponentRef Id="cmpPSALERTSUserGuideChm" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="dirSPEnergyNetworks" Name="SP Energy Networks">
<!-- <Component Id="cmpDirSPEnergyNetworks" Guid="{####################################}" Transitive="yes" /> -->
<Directory Id="dirPSALERTS" Name="PSALERTS">
<!-- <Component Id="cmpDirPSALERTS" Guid="{####################################}" Transitive="yes" /> -->
<Directory Id="dirQuery" Name="Query">
<Component Id="cmpDirQuery" Guid="{####################################}" KeyPath="yes">
<CreateFolder Directory="dirQuery" />
<RemoveFile Id="PurgeQuery" Name="*.*" On="uninstall" />
<RemoveFolder Id="idDirQuery" On="uninstall" Directory="dirQuery" />
</Component>
<Directory Id="dirQueryOutput" Name="QueryOutput">
<Component Id="cmpDirQueryOutput" Guid="{####################################}">
<CreateFolder Directory="dirQueryOutput" />
<RemoveFile Id="PurgeQueryOutput" Name="*.*" On="uninstall" />
<RemoveFolder Id="idDirQueryOutputRemove" On="uninstall" Directory="dirQueryOutput" />
</Component>
</Directory>
<Component Id="cmpQueryExe" Guid="*">
<File Id="filQueryExe" KeyPath="yes" Source="$(var.SourceDir)\Query.exe" />
<RemoveRegistryKey Id="RemoveQueryRegKey" Root="HKLM" Key="####################################" Action="removeOnUninstall" />
</Component>
<Component Id="cmpQueryPdb" Guid="*">
<File Id="filQueryPdb" KeyPath="yes" Source="$(var.SourceDir)\Query.pdb" />
</Component>
<Component Id="cmpBusinessLogicDll" Guid="*">
<File Id="filBusinessLogicDll" KeyPath="yes" Source="$(var.SourceDir)\BusinessLogic.dll"/>
</Component>
<Component Id="cmpBusinessLogicPdb" Guid="*">
<File Id="filBusinessLogicPdb" KeyPath="yes" Source="$(var.SourceDir)\BusinessLogic.pdb" />
</Component>
<Component Id="cmpBusinessObjectDll" Guid="*">
<File Id="filBusinessObjectDll" KeyPath="yes" Source="$(var.SourceDir)\BusinessObject.dll" />
</Component>
<Component Id="cmpBusinessObjectPdb" Guid="*">
<File Id="filBusinessObjectPdb" KeyPath="yes" Source="$(var.SourceDir)\BusinessObject.pdb" />
</Component>
<Component Id="cmpCommonDll" Guid="*">
<File Id="filCommonDll" KeyPath="yes" Source="$(var.SourceDir)\Common.dll" />
</Component>
<Component Id="cmpCommonPdb" Guid="*">
<File Id="filCommonPdb" KeyPath="yes" Source="$(var.SourceDir)\Common.pdb" />
</Component>
<Component Id="cmpDataAccessDll" Guid="*">
<File Id="filDataAccessDll" KeyPath="yes" Source="$(var.SourceDir)\DataAccess.dll" />
</Component>
<Component Id="cmpDataAccessPdb" Guid="*">
<File Id="filDataAccessPdb" KeyPath="yes" Source="$(var.SourceDir)\DataAccess.pdb" />
</Component>
<Component Id="cmpDPAPIHelperDll" Guid="*">
<File Id="filDPAPIHelperDll" KeyPath="yes" Source="$(var.SourceDir)\DPAPIHelper.dll" />
</Component>
<Component Id="cmpDPAPIHelperPdb" Guid="*">
<File Id="filDPAPIHelperPdb" KeyPath="yes" Source="$(var.SourceDir)\DPAPIHelper.pdb" />
</Component>
<Component Id="cmpLoggerDll" Guid="*">
<File Id="filLoggerDll" KeyPath="yes" Source="$(var.SourceDir)\Logger.dll" />
</Component>
<Component Id="cmpLoggerPdb" Guid="*">
<File Id="filLoggerPdb" KeyPath="yes" Source="$(var.SourceDir)\Logger.pdb" />
</Component>
<Component Id="cmpPSALERTSIni" Guid="*">
<File Id="filPSALERTSIni" KeyPath="yes" Source="$(var.SourceDir)\PSALERTS.ini" />
</Component>
<Component Id="cmpPSALERTSXltm" Guid="*">
<File Id="filPSALERTSXltm" KeyPath="yes" Source="$(var.SourceDir)\PSALERTS.xltm" />
</Component>
<Component Id="cmpPSALERTSUserGuideChm" Guid="*">
<File Id="filPSALERTSUserGuideChm" KeyPath="yes" Source="$(var.SourceDir)\PSALERTSUserGuide.Chm" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
</Fragment>
</Wix>
Set the ARPSYSTEMCOMPONENT to 0. You can add the following line under your < Package ... > line.
<Property Id="ARPSYSTEMCOMPONENT">0</Property>
https://msdn.microsoft.com/en-us/library/windows/desktop/aa367750(v=vs.85).aspx

Wix launches application when uninstalling

I have got a strange problem when using Wix to create a Windows Installer Setup for an application I'm working on.
Basically, when the application uninstalls it seems to be launching the application's executable before finalizing the uninstall. I am not sure why it is doing this as I am a newbie on Wix.
Here is the full Wix code, which I got from here.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define Product_Name="Orbit Invoice System"?>
<?define Product_Manufacturer="Orbit"?>
<?define Product_Name_Short="OIS"?>
<?define Product_Manufacturer_Short="Orbit"?>
<?define MainExeID="MainExeID"?>
<!--<?define Product_Version=!(bind.fileVersion.$(var.MainExeID))?>-->
<?define Product_Version=!(bind.assemblyVersion.$(var.MainExeID))?>
<?define SetupResourcesDir=$(var.SolutionDir)\icons\?>
<Product Id="*" Name="$(var.Product_Name)" Version="$(var.Product_Version)" Manufacturer="$(var.Product_Manufacturer)"
Language="1033"
UpgradeCode="F9A23E67-669B-40E5-9995-D8425D08F35F">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<!--Check for .Net Framework 3.5 SP 1-->
<PropertyRef Id='NETFRAMEWORK40FULL'/>
<Condition Message="This application requires .NET Framework 4.0. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.Product_Name) is already installed."
Schedule="afterInstallValidate"
/>
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="$(var.Product_Name) Setup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<!--Icon must be 16x16-->
<Icon Id="AddRemoveProgramsIcon" SourceFile="$(var.SetupResourcesDir)libra.ico"/>
<Property Id="ARPPRODUCTICON" Value="AddRemoveProgramsIcon" />
<!--<Property Id="ARPHELPLINK" Value="" />-->
<InstallExecuteSequence>
<Custom Action="CleanUpUserData" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE AND NOT REINSTALL</Custom>
<!--<Custom Action="LaunchApplication" Before="InstallFinalize" >UPGRADINGPRODUCTCODE OR REINSTALL OR NOT Installed</Custom>-->
</InstallExecuteSequence>
</Product>
<Fragment>
<CustomAction Id="CleanUpUserData" FileKey="$(var.MainExeID)" ExeCommand="cleanUpUserData" Execute="immediate" Impersonate="yes" Return="ignore"/>
<!--<CustomAction Id="LaunchApplication" FileKey="$(var.MainExeID)" ExeCommand="mustBeSomethingOrTheUpdateWillFailWithError2753" Execute="commit" Impersonate="yes" Return="asyncNoWait"/>-->
</Fragment>
<!--Directory general structure-->
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<!--Program Files-->
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="$(var.Product_Name)" />
</Directory>
<!--Startup Programs Menu-->
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="$(var.Product_Manufacturer)">
<Component Id="ProgramMenuDir" Guid="*" >
<Shortcut Id="UninstallProduct"
Name="Uninstall $(var.Product_Name)"
Target="[SystemFolder]msiexec.exe"
Arguments="/x [ProductCode]"
Description="Uninstalls $(var.Product_Name)" />
<RemoveFolder Id='ProgramMenuDir' On='uninstall' />
<RegistryValue Root='HKCU' Key='Software\$(var.Product_Manufacturer_Short)\$(var.Product_Name_Short)' Type='string' Value='' KeyPath='yes' />
</Component>
</Directory>
</Directory>
<!--Desktop-->
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Fragment>
<!--Directory file structure-->
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="MainExecutable" Guid="*">
<File Id="$(var.MainExeID)" Name="$(var.Product_Name).exe" Source="$(var.Invoice.TargetPath)" DiskId="1" KeyPath="yes" Vital="yes"
Assembly=".net" AssemblyApplication="$(var.MainExeID)">
<Shortcut Id="MainExeDesktop" Directory="DesktopFolder" Name="$(var.Product_Name)" WorkingDirectory="INSTALLFOLDER"
Icon="MainExeIcon.exe"
Description="Launches the $(var.Product_Name) application" Advertise="yes" >
<Icon Id="MainExeIcon.exe" SourceFile="$(var.Invoice.TargetPath)"/>
</Shortcut>
<Shortcut Id="MainExeProgramMenu" Directory="ProgramMenuDir" Name="$(var.Product_Name)" WorkingDirectory="INSTALLFOLDER"
Icon="MainExeIcon.exe"
Description="Launches the $(var.Product_Name) application" Advertise="yes" />
<Shortcut Id="CleanUpLocalFiles" Directory="ProgramMenuDir" Name="CleanUp the Local Files" Arguments="cleanUpUserData" WorkingDirectory="INSTALLFOLDER"
Icon="MainExeIcon.exe"
Description="Cleanup all the downloaded files of the $(var.Product_Name) for the current user" Advertise="yes"/>
</File>
</Component>
<Component Id="MainExecutableConfig" Guid="BDFC3501-CB6A-4C75-A4AE-05C0F7FE2DC2">
<File Id="MainExeConfig" Name="$(var.Product_Name).exe.config" Source="$(var.Invoice.TargetPath).config" DiskId="1" KeyPath="yes" Vital="yes" />
<File Id="InvoiceConfig" Name="InvoiceConfiguration.dll" Source="$(var.Invoice.TargetDir)\InvoiceConfiguration.dll" DiskId="1" Vital="yes" />
<File Id="DocumentFormatOpenXml" Name="DocumentFormat.OpenXml.dll" Source="$(var.Invoice.TargetDir)\DocumentFormat.OpenXml.dll" DiskId="1" Vital="yes" />
<File Id="SalesInvoiceTemplate" Name="SalesInvoiceTemplate.docx" Source="$(var.Invoice.TargetDir)\SalesInvoiceTemplate.docx" DiskId="1" Vital="yes" />
</Component>
</DirectoryRef>
</Fragment>
<!--Components groups-->
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<ComponentRef Id="MainExecutable" />
<!--<ComponentRef Id="Dlls" />
<ComponentRef Id="LetterTemplates"/>-->
<ComponentRef Id="MainExecutableConfig" />
<ComponentRef Id="ProgramMenuDir" />
</ComponentGroup>
</Fragment>
</Wix>
Any ideas?
CleanUpUserData custom action run the $(var.MainExeID) application.
<CustomAction Id="CleanUpUserData" FileKey="$(var.MainExeID)" ExeCommand="cleanUpUserData" Execute="immediate" Impersonate="yes" Return="ignore"/>
The below condition (Installed AND NOT UPGRADINGPRODUCTCODE AND NOT REINSTALL) means the Custom action will be run if setup installed and not in upgrade or reinstall. So it will run in Repair or Uninstall(both will meet this condition). So your application is running in Uninstall.
<Custom Action="CleanUpUserData" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE AND NOT REINSTALL</Custom>
Check more about install and uninstall Conditions here.
After reviewing the answer given by #Vinoth I have changed the 'CleanUpUserData' custom action to this:
<Custom Action="CleanUpUserData" After="InstallInitialize">INSTALLED OR UPGRADINGPRODUCTCODE OR REINSTALL</Custom>
And this has now resolved the problem.