WIX : Merge Module Issue - wix

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.

Related

unable to remove the desktop icon after uninstallation in 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.

WiX - installer ignoring my "perUser" install scope. Why?

I'm trying to build a very simple installer that just installs the package as a "per-user" application. No dialogs, just always install into the local app data folder. And it's ignoring me. And always installing to C:\Program Files.
I've set the InstallScope to "perUser", but left the installation directory as "ProgramFilesFolder". The documentation seems to suggest that that SHOULD get redirected, but that isn't happening.
Setup file below...
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="MyApplication"
Language="1033"
Version="1.0.0"
Manufacturer="MyCompany"
UpgradeCode="19E4E10A-558C-4D4A-BD2A-D6B8060FB917">
<Package
InstallerVersion="500"
Compressed="yes"
InstallPrivileges="limited"
InstallScope="perUser" />
<MajorUpgrade
DowngradeErrorMessage="A newer version of MyApplication is already installed." />
<MediaTemplate
EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MyCompany MyApplication">
<Directory Id="JreFolder" Name="jre"/>
<Directory Id="LibFolder" Name="lib"/>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="MyCompany MyApplication"/>
</Directory>
</Directory>
<DirectoryRef Id="INSTALLDIR">
<Component Id="CMP_MyApplication.exe">
<File Id="FILE_MyApplication.exe" Source="MyApplication.exe" KeyPath="yes"/>
</Component>
<Component Id="CMP_MyApplication.ini">
<File Id="FILE_MyApplication.l4j.ini" Source="MyApplication.l4j.ini" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="CMP_StartMenuShortcut" Guid="0B96A876-70FB-4E8E-8D27-B9B1E40C9B4D">
<Shortcut Id="ApplicationStartMenuShortcut" Name="MyCompany MyApplication" Description="MyCompany MyApplication"
Target="[#FILE_MyApplication.exe]" WorkingDirectory="INSTALLDIR"/>
<RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\MyCompany\MyApplication" Name="Installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="Main Application" Level="1" >
<ComponentGroupRef Id="JreGroup"/>
<ComponentGroupRef Id="LibGroup"/>
<ComponentRef Id="CMP_MyApplication.exe"/>
<ComponentRef Id="CMP_MyApplication.ini"/>
<ComponentRef Id="CMP_StartMenuShortcut"/>
</Feature>
</Product>
</Wix>
If you know that you want to install to the app data folder why use the 'ProgramFilesFolder'?
This will only confuse you (or any other person that will maintain your code) - try using the 'AppDataFolder' instead.

Wix XML Error - The Component/#Directory attribute cannot be specified when the Component element is nested underneath a Directory element

First time doing some Wix practice, so im completely new to it.
Here is my short script:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SampleMSI" Language="1033" Version="1.0.0.0" Manufacturer="Nunya" UpgradeCode="b2c39f9b-1de1-433e-bc59-a3548cc531b9">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Installs Signout Utility" Keywords="Practice,Signout,Utility,MSI,Installer" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SampleMSI" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SampleMSI" />
<Directory Id="APPFOLDER" Name="APPDir" >
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="CMP_ADispOCX"
Guid="5E23B839-35CA-480E-8AFC-2E914BA8E32A"
Directory="INSTALLLOCATION">
<File Id="FILE_ADispocx"
Source="ADisp.ocx"
KeyPath="yes" />
</Component>
<Component Id="CMP_Abtn32ocx"
Guid="98B357F2-C295-4019-A878-885E56AA3BF3"
Directory="INSTALLLOCATION">
<File Id="FILE_Abtn32a20ocx"
Source="btn32a20.ocx"
KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
I just wanted to make sure they are going to the same folder, basic installation check. (it is my first time)
I get this error however:
Error 2 The Component/#Directory attribute cannot be specified when the Component element is nested underneath a Directory element.
I get it twice for each component id I have.
Am I missing something? Im using Wix 3.6 A Developers Guide for reference.
edit: Side question......how do I specify an exact path? like C:\Herp\Derp
You don't need to specify the directory of a Component if you did so already in the ComponentGroup element. Remove the Directory attribute in both Components elements in your fragment.
Change your code to this
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="CMP_ADispOCX"
Guid="5E23B839-35CA-480E-8AFC-2E914BA8E32A">
<File Id="FILE_ADispocx"
Source="ADisp.ocx"
KeyPath="yes" />
</Component>
<Component Id="CMP_Abtn32ocx"
Guid="98B357F2-C295-4019-A878-885E56AA3BF3">
<File Id="FILE_Abtn32a20ocx"
Source="btn32a20.ocx"
KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>

Wix toolset: create directory in root disk (system disk or c:\) and copy files inside

I'm aware of similar questions inside stackoverflow:
WIX:default directory in WixUI_InstallDir,
WIX installer root directory and versioning,
Is it possible to have two root directories in WIX,
copy file to custom dir in another partition,
How to create a directory in wix?
however none of them shows a simple and immediate code to create a folder inside the C:\ folder (not hard coded but should be the root disk or system disk or whatever you would call the disk which contains the Windows folder) and to copy files inside it.
In other words how can Wix create a C:\MynewDir\example.jar folder?
Here's what I tried:
<?xml version="1.0" encoding="UTF-8"?>
<!-- WiX installer MyProgram by Mark Seuffert -->
<?define ProductVersion = "13.1.2.3"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111112"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="MyProgram" Version="$(var.ProductVersion)" Manufacturer="COMPANY" Language="1033">
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MyProgram">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
<File Id="ApplicationFile1" Source="C:\Users\user\Desktop\myprogram.exe" />
</Component>
</Directory>
</Directory>
<Directory Id="ANOTHERLOCATION" FileSource="C:\MynewDir">
</Directory>
</Directory>
<DirectoryRef Id="ANOTHERLOCATION" FileSource="C:\MynewDir">
<Component Id="ApplicationFiles2" Guid="12345678-1234-1234-1235-111111111111">
<File Id="ApplicationFile2" Source="C:\Users\user\Desktop\InstallerFiles_13_4_9_3\myprogramLauncher.jar" />
<CreateFolder />
</Component>
</DirectoryRef>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="ApplicationFiles2" />
<ComponentRef Id="ApplicationFiles" />
</Feature>
</Product>
</Wix>
EDIT 1:
Yan Sklyarenko just found what I was looking for, that's the WindowsVolume (I don't know how I missed it inside http://msdn.microsoft.com/en-us/library/windows/desktop/aa370905%28v=vs.85%29.aspx#system_folder_properties microsoft document).
However how do I replace FileSource="C:\MynewDir" with FileSource="[WindowsVolume]MynewDir" ??? because apparently even with WINDOWSVOLUME the resulting volume chosen is always D:\ in my computer which has more available space :(
EDIT 2 I updated my code using Yan Sklyarenko's second sample ( ####newpart#### identifies parts where code differs), however behaviour is still the same, the installer chooses the disk with more free space (D:\ in my case) and not C:\ where windows is..
<?xml version="1.0" encoding="UTF-8"?>
<!-- WiX installer MyProgram by Mark Seuffert -->
<?define ProductVersion = "13.1.2.3"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111112"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="MyProgram" Version="$(var.ProductVersion)" Manufacturer="COMPANY" Language="1033">
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MyProgram">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
<File Id="ApplicationFile1" Source="C:\Users\user\Desktop\myprogram.exe" />
</Component>
</Directory>
</Directory>
<Directory Id="ANOTHERLOCATION" FileSource="C:\MynewDir">
####newpart####<Component Id="ApplicationFiles2" Guid="12345678-1234-1234-1235-111111111111">
<File Id="ApplicationFile2" Source="C:\Users\user\Desktop\InstallerFiles_13_4_9_3\myprogramLauncher.jar" />
<CreateFolder />
</Component>
</Directory>
</Directory>
####newpart####<SetDirectory Id="ANOTHERLOCATION" Value="[WINDOWSVOLUME]" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="ApplicationFiles2" />
<ComponentRef Id="ApplicationFiles" />
</Feature>
</Product>
</Wix>
EDIT 3 The last code snippet above should work however change the casing of WINDOWSVOLUME to WindowsVolume as suggested.
Here is a complete working solution based on your code simplified (notice the comment in the code):
<?define ProductVersion = "13.1.2.3"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111112"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="MyProgram"
Version="$(var.ProductVersion)" Manufacturer="COMPANY" Language="1033">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MyProgram" />
<Directory Id="ANOTHERLOCATION" />
</Directory>
</Directory>
<!-- The casing of 'ANOTHERLOCATION' and 'WindowsVolume' is very important here.
Replace 'MyNewDir' with the correct name of the folder you want on
WindowsVolume.
-->
<SetDirectory Id="ANOTHERLOCATION" Value="[WindowsVolume]MyNewDir" />
<Feature Id="DefaultFeature" Level="1">
<Component Directory="INSTALLDIR">
<File Id="ApplicationFile1" Source="C:\Users\user\Desktop\myprogram.exe" />
</Component>
<Component Directory="ANOTHERLOCATION">
<File Id="ApplicationFile2" Source="C:\Users\user\Desktop\InstallerFiles_13_4_9_3\myprogramLauncher.jar" />
</Component>
</Feature>
</Product>
</Wix>
Ok, you can do something like this:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WindowsVolume">
<Directory Id="MyNewDirId" Name="MyNewDir">
<Component Id="SampleComponent" Guid="...">
<File Id="SampleFile" Source="..." KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
This will install the file to the MyNewDir folder on Windows drive (C: in my case).
However, it will complain that using WindowsVolume in this fashion might have unexpected side effects.
To satisfy that validation, you can change the sample to:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="MyNewDirId" Name="MyNewDir">
<Component Id="SampleComponent" Guid="...">
<File Id="SampleFile" Source="..." KeyPath="yes" />
</Component>
</Directory>
</Directory>
<SetDirectory Id="MyNewDirId" Value="[WindowsVolume]MyNewDir" />
This looks more like a hack, but the result is the same.
To be honest, I don't understand what those "unexpected side effects" could be. Maybe, Windows Installer gurus can shed some light on this.
Hope this helps.

WiX 3 driving me crazy - trying to create desktop shortcut

I have an app that is being installed with WiX 3 - most of the install works fine by now, but trying to get the desktop shortcut to work seems to cost me my mind...
I have my app being installed and I already have a shortcut on the Start Menu folder - works just fine. But how do I get the desktop shortcut up and running?
<Product Id="*" Name="....." UpgradeCode="MY-GUID">
<Package Id="*" InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="foobar.cab" EmbedCab="yes" />
<Property Id="ALLUSERS">1</Property>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="FooBar"/>
</Directory>
<Directory Id="DesktopFolder" SourceName="Desktop"/>
<Directory Id="ProgramFilesFolder">
<Directory Id="FoobarDir" Name="FOOBAR">
<Directory Id="INSTALLLOCATION" Name="FooApp">
<Component Id="MainFiles" Guid=".....">
<File Id="FooMainApp" Source="FooMainApp.exe" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
....
<!-- this shortcut here works just fine ... -->
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="AppShortcut" Guid="...">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="FooBarApp" Description="..."
Target="[INSTALLLOCATION]FooMainApp.exe"
WorkingDirectory="INSTALLLOCATION"/>
</Component>
</DirectoryRef>
<!-- but this shortcut here never seems to work .. ... -->
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="....." >
<Shortcut Id="DesktopAppShortcut"
Advertise="no"
Name="FooBarApp" Description="...."
Target="[INSTALLLOCATION]FooMainApp.exe"
WorkingDirectory="INSTALLLOCATION"/>
</Component>
</DirectoryRef>
The errors I keep getting are:
ICE18: KeyPath for Component:
'DesktopShortcut' is Directory:
'DesktopFolder'. The
Directory/Component pair must be
listed in the CreateFolders table.
ICE38: Component DesktopShortcut
installs to user profile. It must use
a registry key under HKCU as its
KeyPath, not a file.
ICE43: Component
DesktopShortcut has non-advertised
shortcuts. It should use a registry
key under HKCU as its KeyPath, not a
file.
I do not understand what on earth WiX 3 / Windows Installer is trying to tell me here.... anyone??
Both components, AppShortcut and DesktopShortcut, are in fact part of the "main" feature - I don't see any issue there. I can't figure out what on earth could be wrong here....
Update: ok, so I added some registry key stuff to my desktop shortcut
<Component Id="DesktopShortcut" Guid="BF3587B4-F52E-411E-8814-CFCBF8201C0D">
<RegistryKey Root="HKCU" Key="Software\Foo Inc\FooBarApp\Installed"
Action="createAndRemoveOnUninstall">
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes"/>
</RegistryKey>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
Name="FooBar" WorkingDirectory="INSTALLLOCATION"
Icon="foobar.ico"
Target="[INSTALLOCATION]FooMainApp.exe"/>
</Component>
now the ICE messages are gone, but when I try to install the app, I get Error 1909 - the target folder doesn't exist, or you do not have permission to write to it (or something like that)
Update 2: the above sample code provided does work on Win XP, but it keeps failing on Win Server 2003 :-( Any further ideas??
Here's a working example from our live production code...
<Fragment>
<Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
<RegistryValue Id="RegShortcutDesktop" Root="HKCU"
Key="SOFTWARE\ACME\settings" Name="DesktopSC" Value="1"
Type="integer" KeyPath="yes" />
<Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]MyApp.exe"
Directory="DesktopFolder" Name="My Application"
Icon="$(var.product).ico" IconIndex="0"
WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
</Component>
</Fragment>
This is based on #saschabeaumont's answer, but hopefully with some extra helpful hints for us WiX beginners (is it a nightmare for everybody to learn???).
First, create a fragment that contains the shortcut details itself:
<Fragment>
<Component Id="DesktopShortcut" Directory="INSTALLFOLDER" Guid="*">
<RegistryValue Id="RegShortcutDesktop"
Root="HKCU"
Key="Software\Company\ApplicationName"
Name="DesktopSC"
Value="1"
Type="integer"
KeyPath="yes" />
<Shortcut Id="desktopSC"
Target="[INSTALLFOLDER]ApplicationName.exe"
WorkingDirectory="INSTALLFOLDER"
Icon="icon.ico"
Directory="DesktopFolder"
Name="ApplicationName"
Advertise="no"/>
</Component>
</Fragment>
Next, note that this fragment will need including in the Product element, like this:
<Feature Id="ProductFeature" Title="Your Application Title" Level="1">
...
<ComponentRef Id="DesktopShortcut" />
</Feature>
The ProductFeature will likely contain other fragments, such as files, and the program menu shortcut fragment.
Also, the DesktopFolder will need a reference in the TARGETDIR directory element (which will very likely contain other folders, such as ProgramMenuFolder as you require), like this:
<Directory Id="TARGETDIR" Name="SourceDir">
...
<Directory Id="DesktopFolder" Name="Desktop"/>
</Directory>
Each of these ICE messages is basically complaining about the same thing: a component installing a shortcut should have a registry entry as its keypath. To fix this, add something like this to the component:
<RegistryValue Root="HKCU" Key="Software\MyCompany\MyApplicationName"
Name="desktopShortcut" Type="integer" Value="1" KeyPath="yes"/>
The same goes for the component installing the start menu shortcut. Take a look at the related wix documentation sample about creating a shortcut.
My purpose is to create an internet shortcut link and put to desktop. Here is the code that works for me:
<?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="09F1B63D-FB03-43FD-A326-FD49F93D00C8" Name="TestProduct" Language="1033" Version="0.0.0.1" Manufacturer="WixEdit" UpgradeCode="6B2F9AB4-73A6-45CB-9EC4-590D1AAA6779">
<Package Description="Test file in a Product" Comments="Simple test" InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Name="AAAA" Id="AAABBB">
<Component Id="AAAA">
<File Id="AAAA.EXE" Name="AAAA.exe" Source="U:\web\bin\x86\Release\AAAA.exe" />
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder">
<Component Id="StartMenuShortcuts" Guid="E8EDD7BC-9762-4C3D-8341-FAEC983D318A">
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" />
<util:InternetShortcut Id="WebsiteShortcut" Name="AAAA Website" Target="http://www.AAAA.com" />
</Component>
</Directory>
</Directory>
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<ComponentRef Id="StartMenuShortcuts" />
<ComponentRef Id="AAAA" />
</Feature>
<UI />
</Product>
</Wix>
NOTE: you need to add the following to your candle and light command lines: -ext WiXUtilExtension
Not sure if this was available back in 2010, but this is how I do it in WiX 3.7:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" SourceName="Desktop" />
<Directory Id="MergeRedirectFolder">
<Component Id="MyExeComponent" Guid="{PUT-GUID-HERE}">
<File Id="MyExeFile" Source="$(var.ExeSourcePath)" KeyPath="yes">
<Shortcut
Id="DesktopShortcut"
Directory="DesktopFolder"
Name="$(var.ShortcutName)"
WorkingDirectory="MergeRedirectFolder" />
</File>
</Component>
</Directory>
</Directory>