unable to remove the desktop icon after uninstallation in WIX - wix

I am using WIX installer for my application everything working fine but when I uninstall the application the desktop icon and startmenu icon is still there.
Whats wrong with my xml. followed the steps given by Wix documentation.
help..
XML:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="applicationName" Language="1033" Version="1.0.0.0" Manufacturer="manufacturerName" UpgradeCode="PUT-GUID-HERE">
<Package Id="*" InstallerVersion="201" Compressed="yes" InstallScope="perMachine" Comments="Windows Installer Package" ReadOnly="yes" InstallPrivileges="elevated" />
<Feature Id="ProductFeature" Title="applicationName" Level="1">
<ComponentRef Id="Permission.INSTALLFOLDER" />
<ComponentRef Id="ApplicationDeskShortcutComp" />
<ComponentGroupRef Id="HeatGenerated" />
</Feature>
<Media Id="1" Cabinet="cab1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="CompanyNameFolder" Name="CompanyName">
<Directory Id="INSTALLFOLDER" Name="applicationName">
<Component Id="Permission.INSTALLFOLDER" Guid="*">
<CreateFolder>
<Permission User="Everyone" GenericAll="yes" />
</CreateFolder>
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="applicationName" />
</Directory>
</DirectoryRef>-->
<!--Add the shortcut to installer package For DeskTop-->
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationDeskShortcutComp" Guid="*" Win64="yes" >
<Shortcut Id="ApplicationDeskShortcut" Name="applicationName" Description="applicationName" Target="[INSTALLFOLDER]exeName.exe" WorkingDirectory="DesktopFolder" Icon="IconName.exe" >
</Shortcut>
<RemoveFolder Id="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Manufacturer\ProductName" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<Property Id="MYWIXUI_MONDO" Value="INSTALLFOLDER" />
<UIRef Id="MyWixUI_Mondo" />
<Icon Id="IconName.exe" SourceFile=".\Icons\MainLogo.ico" />
<Property Id="ARPPRODUCTICON" Value="IconName.exe" />
</Wix>

No time to test this right now, but could you first please try to change this:
<Directory Id="DesktopFolder" Name="applicationName" />
into this:
<Directory Id="DesktopFolder" />
DesktopFolder is a built-in Windows Installer folder that should resolve to the user's desktop folder or the common desktop folder for all users depending on the setting for ALLUSERS (per-machine or per-user installation).
During installation, MSI directory resolution (costing) will assign the correct value to DesktopFolder for the system you are running on (based on ALLUSERS setting). I thought anything you assign to DesktopFolder yourself in your WiX source would be wiped out as soon as directory resolution has run, so there is no direct logical reason why the above WiX markup change suggestion should work, but I think it should be tested. Please test on a clean virtual, if available.

Related

How to make changing MSI install folder work in WiX?

I created a MSI installer to install per-user.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Id="*"
Language="1033"
Manufacturer="my company"
Name="my software"
UpgradeCode="{9B85A1B0-6914-4573-92C1-27A6DB849E1D}"
Version="2.0.0.0">
<Package
Compressed="yes"
Description="a software"
InstallerVersion="500"
InstallScope="perUser"
Manufacturer="my company"
Comments="copyright" />
<MediaTemplate EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="AppDataFolder">
<Directory Id="ManufacturerFolder" Name="MyCompany">
<Directory Id="INSTALLFOLDER" Name="MySoftware">
</Directory>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="ManufacturerFolder">
<Component Id="cmp_manufacturer" Guid="{264B9740-7BF6-4D90-9F0A-5B9489687C96}">
<RegistryValue
Root='HKCU'
Key='Software\MyCompany\MySoftware\Product'
Name='reg_manufacturer'
Value='manufacturer'
Type='string'
KeyPath='yes' />
<RemoveFolder Id="removeManufacturerFolder" On="uninstall" />
</Component>
</DirectoryRef>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp_install" Guid="{0CF4AFFB-9676-4944-BCE7-9B0F54704677}">
<RegistryValue
Root='HKCU'
Key='Software\MyCompany\MySoftware\Product'
Name='reg_install'
Value='install'
Type='string'
KeyPath='yes' />
<File Id="file_install" Source="installfile.txt" />
<RemoveFolder Id="removeInstallFolder" On="uninstall" />
</Component>
</DirectoryRef>
<UIRef Id="WixUI_InstallDir" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<Feature
Id="MainFeature"
Title="My Software"
Level="1">
<ComponentRef Id="cmp_manufacturer" />
<ComponentRef Id="cmp_install" />
</Feature>
</Product>
</Wix>
It works well if using default install folder C:\Users\xxx\AppData\Roaming\MyCompany\MySoftware. The file installfile.txt can be removed on uninstall. If I changed the install folder to a different folder using the WiXUI, the file installfile.txt can be copied to the right folder, But the copied file cannot be removed on uninstall. So why that file cannot be removed on uninstall, how to fix this?
I'll appreciate any help.

WIX Single Package Installer - Per machine Shortcuts

I followed this for getting a functioning Per-User/Per-machine installer working using ALLUSERS=2. Now, my issue is regarding getting shortcuts working properly with this setup. If I set MSIINSTALLPERUSER=1 (Single User) then my Desktop and StartMenu shortcuts are always added per user in the HKCU. If I set MSIINSTALLPERUSER={}, then I can get shortcuts per machine. In the custom UI, MSIINSTALLPERUSER is being set based on the selected radio button in the advanced portion of the UI. So, although the shortcuts are created last and their registry values are set to HKMU, the installer always chooses where to put the shortcuts based on the initial value of MSIINSTALLPERUSER.
Can anyone point me in the right direction to properly creating shortcuts based on the type of install selected in the advanced UI (Per User / Per Machine).
Here is my Product.wxs
`
<?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="HearCon" Language="1033" Version="2.0.299" Manufacturer="Tremetrics" UpgradeCode="73765816-7ba9-4a2b-89c3-ce1f26863b53">
<Package InstallerVersion="500" Compressed="yes" />
<MediaTemplate EmbedCab="yes" />
<Condition Message="Only Windows 7 and newer are supported">
<![CDATA[Installed OR VersionNT >= 601]]>
</Condition>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="Application" Level="1">
<ComponentGroupRef Id="HearConGroup" />
<ComponentRef Id="RA660Folder_Permission" />
</Feature>
<Feature Id="DesktopShortcutFeature" Title="Desktop Shortcut" Level="1">
<ComponentRef Id="DesktopShortcut" />
</Feature>
<Feature Id="StartMenuShortcutFeature" Title="Start Menu Shortcut">
<ComponentRef Id="ProgramMenuShortcut" />
<Condition Level="1">Privileged</Condition>
</Feature>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="HearCon" />
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
<Directory Id="ProgramMenuFolder" />
<Directory Id="CommonAppDataFolder">
<Directory Id="RA660Folder" Name="RA660">
<Directory Id="RA660Driver" Name="Drivers" />
</Directory>
</Directory>
</Directory>
<Property Id="WixAppFolder" Value="WixPerUserFolder" />
<Property Id="ApplicationFolderName" Value="HearCon" />
<Property Id="ALLUSERS" Value="2" />
<Property Id="DISABLEADVTSHORTCUTS" Value="1" />
<Property Id="MSIINSTALLPERUSER" Value="1" />
<UIRef Id="WixUI_CustomAdvanced" />
<WixVariable Id="WixUIBannerBmp" Value="HearConBanner.bmp" />
</Product>
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="10E3E42D-8B2E-471D-A6F9-6263C3491D4C">
<RegistryValue Root="HKMU" Key="Software\Tremetrics\HearCon" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="ProgramMenuFolder">
<Component Id="ProgramMenuShortcut" Guid="2C7EA878-B1B1-4B64-937A-6B583ED5E9B3">
<RegistryValue Root="HKMU" Key="Software\Tremetrics\HearCon" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="RA660Folder">
<Component Id="RA660Folder_Permission" Guid="0A538414-E53F-470E-9546-7EF193878F05">
<CreateFolder>
<util:PermissionEx User="Users" GenericAll="yes"/>
</CreateFolder>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
`

Why file get overwritten when KeyPath is set in Wix

The snippet of Files.wxs generated by heat:
<?xml version="1.0" encoding="utf-8"?>
<Wix
xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Directory Id="dirF5D9BDF13CBC346EDDFD6D0959FFB838" Name="config">
<Component Id="cmp0CBEDCE6B62E5666B3362D0EB41267BC" Guid="*">
<File Id="fil73D1987B7864F07C97735D7E40243AB2" KeyPath="yes"
Source="$(var.App.TargetDir)\config\accounts-example.ini" />
</Component>
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Binaries">
<ComponentRef Id="cmp0CBEDCE6B62E5666B3362D0EB41267BC" />
</ComponentGroup>
</Fragment>
</Wix>
Product.wxs:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="xxx" Language="2052" Version="$(var.ProductVersion)" Manufacturer="xxx"
UpgradeCode="425BDA6F-31B8-47AD-88D8-4B2DBE394XXX">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="New Version [ProductName] has been installed。" />
<MediaTemplate EmbedCab="yes" />
<WixVariable Id="WixUILicenseRtf" Value="./License.rtf" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MANUFACTURERFOLDER" Name="!(bind.property.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="!(bind.property.ProductName)" />
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="XXX_Installer" Level="1">
<ComponentGroupRef Id="Binaries" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentRef Id="RegistryEntries" />
</Feature>
<UIRef Id="WixUI_ErrorProgressText" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="E1F61345-CC60-40FE-8FC4-FBE1598F8XXX">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="!(bind.property.ProductName)"
Description="!(bind.property.ProductName)"
Target="[INSTALLFOLDER]XXX_App.exe"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Microsoft\!(bind.property.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop" Guid="BEDF111F-0889-4317-8E67-41425F00CXXX">
<Shortcut Id="ApplicationDesktopShortcut"
Name="!(bind.property.ProductName)"
Description="!(bind.property.ProductName)"
Target="[INSTALLFOLDER]XXX_App.exe"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Microsoft\!(bind.property.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="0D919675-E219-43EA-AAB3-E6F81A013XXX">
<RegistryKey Root="HKCU"
Key="Software\Microsoft\Windows\CurrentVersion\Run">
<RegistryValue Name="!(bind.property.ProductName)"
Type="string"
Value="[INSTALLFOLDER]XXX_App.exe"/>
</RegistryKey>
</Component>
</DirectoryRef>
<UI>
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="启动!(bind.property.ProductName)" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<Property Id="WixShellExecTarget" Value="[INSTALLFOLDER]XXX_App.exe" />
<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
</Product>
</Wix>
Every time I install a new version, it overwrites the existing file accounts-example.ini.
The overwrite behavior is expected for accounts-example.ini, but I will have another file user.db do not want to be overwritten.
It says if KeyPath is set to 'yes' then it doesn't overwrite the existing file, isn't it? How could I config Wix to overwrite one file and not overwirte another?
Some articles about KeyPath:
what-is-the-wix-keypath-attribute
copy-if-not-exist-in-wix
If you are doing this with a majorupgrade element you need to tell us where it's scheduled. If it's "early" (such as afterInstallInitialize) then everything will be uninstalled first, and then the new upgrade installed, and every file that was installed will be from the new upgrade. If it's sequenced "late" (such as afterInstallExecute) then the overwrite rules apply (such as this https://msdn.microsoft.com/en-us/library/windows/desktop) and that's because the upgrade basically installs each file over the existing files.
Note that the WiX default for the MajorUpgrade schedule is afterInstallValidate, so as I described (and as the WiX documentation says) the entire older product will be uninstalled first (obviously removing all files) then all the new files will be installed.
See schedule here:
http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html
The explanation at the WiX keypath link leaves a lot to be desired. It is not really true to say that if the component is present none of its resources will be installed. It's not clear to me what that is intended to mean because the overwrite rules will be applied.
As far as your data files are concerned, they will not be overwritten by an incoming file if they have been updated since they were installed. So it's likely that your ini file is being overwritten because it hasn't been changed. If your db has been updated then it won't be replaced, but, again, this is overwrite rules when your major upgrade is "late" (or it's a patch).

Wix : adding my heat harvested files

I have been struggling with Wix for the last couple of days, probably read 15 guides around the web so far trying to make it working on my real application, but no luck.
I used a small and simple other project to practice and make sure I understand and do every thing right.
Following this guide I managed to got it to work, the next stage was trying to add the content of the directory to the installation since it holds many files that I dont want to add by hand.
So following this guide I used heat.exe to harvest the content of the folder, I got the heat to create the .wxs that I needed but next is trying to add its content to my Product.wxs file.
Problem is that it says I should add this:
<!-- Add ComponentGroupRef to existing Feature, or create new one -->
<!-- Notice the IDs & what we used in heat -->
<Feature Id="ProductFeature" Title="Main product" Level="1">
<ComponentGroupRef Id="ConfigurationUtilityComponents"/>
</Feature>
<Fragment>
<Directory Id="INSTALLDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ConfigurationUtilityDir" Name="ConfigurationUtility" />
</Directory>
</Directory>
</Fragment>
to my Product.wxs file , but I cant seem to figure out how to do it.
Can any one please help?
Here is my Product.wxs file:
<Product Id="8748CF04-E8D3-4A2B-B3F5-22E50B3A8E49"
Name="MyApp" Language="1033" Version="1.0.0.0" Manufacturer="My System Pvt Ltd"
UpgradeCode="8748CF04-E8D3-4A2B-B3F5-22E50B3A8E49">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
InstallPrivileges="elevated" ReadOnly="yes"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--Add Cab1.cab File inside the Package-->
<Media Id="1" Cabinet="cab1.cab" EmbedCab="yes" />
<!--Here We Install Our Main App-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MY System Pvt Ltd"/>
</Directory>
<!-- Step 1: For the Program Menu -->
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="My System Pvt Ltd"/>
</Directory>
<!--Step 2:For Desktop Folder-->
<Directory Id="DesktopFolder"/>
<!--Step 3:For StartUp Folder-->
<Directory Id="StartupFolder"/>
</Directory>
<!--Step 4 :Add Main App exe-->
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="myapplication.exe" Guid="84C5B9E8-FD90-4EA8-A502-B08AC9B38D39">
<File Source="$(var.WpfApplication2.TargetPath)" Name="MYApp.exe"
Id="MyAppEXE" KeyPath="yes"/>
</Component>
</DirectoryRef>
<!-- Step 1.1: Add the shortcut to your installer package Program Menu or Start Menu-->
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="1A437020-D5C9-450C-9B3D-33957994780A">
<!--Add Shortcut of the Application in start Menu-->
<Shortcut Id="ApplicationStartMenuShortcut" Name="MyApp" Description="My Application Description"
Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER">
<!--Add Icon to the ShortCut-->
<Icon Id="MYPMenuIcon" SourceFile=".\Desktop.ico" />
</Shortcut>
<!--Remove the Folder At time of Uninstall-->
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key='Software\[Manufacturer]\[ProductName]'
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<!-- Step 2.1: Add the shortcut to your installer package For DeskTop-->
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationDeskShortcutComp" Guid="40127963-856D-460D-9E1B-4C10EB65835B">
<Shortcut Id="ApplicationDeskShortcut" Name="MYAppDesk"
Description="My Application Description" Target="[INSTALLFOLDER]MyApp.exe"
WorkingDirectory="INSTALLFOLDER">
<Icon Id="MYDeskIcon" SourceFile=".\Desktop.ico" />
</Shortcut>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key='Software\[Manufacturer]\[ProductName]'
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<!--Step 3.1: add Shortcut to StartUp Folder to run application when you login-->
<DirectoryRef Id="StartupFolder">
<Component Id="ApplicationStartUpShortcutComp" Guid="843B6A2E-AB61-40C7-BE49-FBCD7F81E35D">
<Shortcut Id="ApplicationStartUpDeskShortcut" Name="MYAppDesk" Description="My Application Description"
Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER">
<Icon Id="MyIconStartUp" SourceFile=".\Desktop.ico" />
</Shortcut>
<RemoveFolder Id="StartupFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key='Software\[Manufacturer]\[ProductName]'
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<!--Add Component-->
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="myapplication.exe" />
<!--Step 1.2:Add Start menu or program Shortcut-->
<ComponentRef Id="ApplicationShortcut" />
<!--step 2.2Add DeskTop Shortcut-->
<ComponentRef Id="ApplicationDeskShortcutComp" />
<!--step 3.2Add DeskTop Shortcut-->
<ComponentRef Id="ApplicationStartUpShortcutComp"/>
<ComponentRef Id="dotNetClass.Output" />
<!--<ComponentRef Id="AU" />-->
</Feature>
</Product>
I kind of get where your coming from, I tried to link my Heat produced code to the product .wxs file.. What I did is, add the heat source code (.wxs) file to your project..
on the first Component group, Note down the name e.g
<ComponentGroup Id="SampleGroup">
Then in this section
<Feature Id="ProductFeature" Title="Random Desktop" Level="1">
<ComponentGroupRef Id="SampleGroup" />
</Feature>
</Product>
Make sure both names match, where it says "SampleGroup"

WIX : Merge Module Issue

When I try to use merge module feature in VS2010, I am getting an issue "Multiple Section entery"
Why i am getting this error?
I have done googling but I did not get any thread where i got my answer.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Module Id="ModuleTest" Language="1033" Version="1.0.0.0">
<Package Id='94290AA7-50E3-414E-A1BD-FC3C2B0C47D8' Description='My first Merge Module'
Comments='This is my first attempt at creating a Windows Installer Merge Module'
Manufacturer='TravelPort Private Limited' InstallerVersion='200' />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='MyModuleDirectory' Name='.'>
<Component Id='MyModuleComponent' Guid='93F36B4B-B6E0-4000-8174-2660C0AE9D6A'>
<File Id='readme' Name='ReadMeModule' Source='ReadMergeModule.txt' DiskId='1' KeyPath='yes' Checksum='yes'></File>
</Component>
</Directory>
</Directory>
</Module>
</Wix>
product.wxs file
<Product Id="ec20ec5e-bb50-45d0-9190-156cf146c8f3" Name="WinDemoApp" Language="1033" Version="1.0.0.0" Manufacturer="WinDemoApp" UpgradeCode="979e03f4-3b50-43c1-9dde-dd675f726fde">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="WinDemoApp">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
</Directory>
<Directory Id ="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="WinDemoApp"></Directory>
</Directory>
<!--<Merge Id='MyModule' Language='1033' SourceFile='Module.msm' DiskId='1' />-->
</Directory>
</Directory>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="MyApp.exe" Guid="36AA7C63-ED57-40C6-8B14-843B9355C265">
<File Id="MyApp.exe" Source="D:\WIXDemo\WinDemoApp\MyApp\bin\Debug\MyApp.exe" KeyPath="yes" Checksum="yes"></File>
</Component>
</DirectoryRef>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="EA549460-4D98-4B09-B621-D4F1AA12A617">
<Shortcut Id="ApplicationStartMenuShortcut" Name="WinDemoApp"
Description="My Win Installer sample"
Target="[APPLICATIONROOTDIRECTORY]MyApp.exe"
WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
<RemoveFolder Id ="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\WinDemoApp" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<!--<Icon Id="bug.ico" SourceFile="bug.ico"/>
<Property Id="ARPPRODUCTICON" Value="bug.ico" />-->
<Feature Id="MyApplication" Title="WinDemoApp" Level="1">
<!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
<ComponentRef Id="MyApp.exe"/>
<ComponentRef Id="ApplicationShortcut"/>
<!--<MergeRef Id="MyModule"/>-->
<!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->
</Feature>
</Product>
The MyModuleDirectory directory element shouldn't have a name attribute. Also your Merge element should probably be nested underneath the ApplicationProgramsFolder directory. Where it's now it'll go to [ProgramFilesFolder].
Take a look at Industrial Strength Windows Installer XML.
Even if you don't want to use the tool, it's own installer is setup exactly the way you are setting up yours with merge modules consumed by a product.