[wix-users] Understanding Existing Code
Edwin Castro
egcastr at gmail.com
Mon Jul 27 17:31:08 PDT 2020
All Components must be associated with a Directory. Defining the registry
Components directly under the Directory structure ensures the association
is present..... I don't think your second example will compile as written.
Those "free-floating" Components will need a Directory attribute or must be
defined in a ComponentGroup with a Directory attribute.
--
Edwin G. Castro
On Mon, Jul 27, 2020 at 4:30 PM Todd Hoatson via wix-users <
wix-users at lists.wixtoolset.org> wrote:
> Hi all,
> just wanting to double-check my thinking about some code we have (that I
> didn't write, so I want to be sure I understand the logic)...
>
> Our main WiX file for our full-release installer has the following code
> (I've simply changed some names):
>
> <Icon Id="CoolApp_Icon.ico" SourceFile=".\resources\CoolApp.ico" />
>
> <Directory Id='ProgramFilesFolder'>
> <Directory Id='APPFOLDER' Name='CoolApp 8'>
> <Component Id='RegKeyValues' Guid='*'>
> <RegistryKey Root='HKLM' Key='SOFTWARE\CoolApp\8'>
> <RegistryValue Name="CoolApp_Files_Directory"
> Type='string' Value='[APPFOLDER]'/>
> <RegistryValue Name="CoolAppVersion" Type='string'
> Value='$(var.VersionNumber)'/>
> </RegistryKey>
> </Component>
>
> <Component Id='RegKeySettingsDir' Guid='*' Permanent='yes'>
> <RegistryKey Root='HKLM' Key='SOFTWARE\CoolApp\8'>
> <RegistryValue Name="Settings_Directory" Type='string'
> Value='[PROJFOLDER]'/>
> </RegistryKey>
> </Component>
>
> <Component Id='CoolAppIcon' Guid='*'>
> <File Id='CoolAppIconFile' Name='CoolApp.ico'
> Source='.\resources\CoolApp.ico' KeyPath='yes'/>
> </Component>
> </Directory>
> </Directory>
>
> <DirectoryRef Id="ProgramMenuFolder">
> <Component Id="ApplicationShortcutMenu" Guid="*">
> <Shortcut Id="ApplicationStartMenuShortcut"
> Name="CoolApp 8"
> Target="[APPFOLDER]CoolApp.exe"
> WorkingDirectory="APPFOLDER"
> Icon="CoolApp_Icon.ico"/>
> <RegistryValue Root="HKCU" Key="Software\Microsoft\CoolApp 8"
> Name="installed" Type="integer" Value="1" KeyPath="yes"/>
> </Component>
> </DirectoryRef>
>
> First, I encountered a problem where the AppIcon is left behind when the
> app is uninstalled. I can't see from this code why that would happen. I'm
> actually not sure why the AppIcon is being copied to the APPFOLDER in the
> first place. As long as the shortcuts are created with the icon file,
> there shouldn't be any need for an icon file in the APPFOLDER, right?
>
> Second, it seems like the registry value related to the shortcut should NOT
> have Microsoft as part of its key, correct?
>
> Third, I don't really see any need for the Registry Key with the Name
> "Settings_Directory" to be handled in this Directory element. There seems
> to be no relation between the two. Am I missing something? Maybe it's
> just here so the code related to registry keys is kept in the same
> place...?
>
> So, I wondered about separating the registry key stuff from the directory
> elements, like so (similar to another app installer I worked on):
>
> <Icon Id="CoolApp_Icon.ico" SourceFile=".\resources\CoolApp.ico" />
>
> <Directory Id='ProgramFilesFolder'>
> <Directory Id='APPFOLDER' Name='CoolApp 8' />
> </Directory>
>
> <DirectoryRef Id="ProgramMenuFolder">
> <Component Id="ApplicationShortcutMenu" Guid="*">
> <Shortcut Id="ApplicationStartMenuShortcut"
> Name="CoolApp 8"
> Target="[APPFOLDER]CoolApp.exe"
> WorkingDirectory="APPFOLDER"
> Icon="CoolApp_Icon.ico"/>
> <RegistryValue Root="HKCU" Key="Software\Microsoft\CoolApp 8"
> Name="installed" Type="integer" Value="1" KeyPath="yes"/>
> </Component>
> </DirectoryRef>
>
> <Component Id='RegKeyValues' Guid='*'>
> <RegistryKey Root='HKLM' Key='SOFTWARE\CoolApp\8'>
> <RegistryValue Name="CoolApp_Files_Directory" Type='string'
> Value='[APPFOLDER]'/>
> <RegistryValue Name="CoolAppVersion" Type='string'
> Value='$(var.VersionNumber)'/>
> </RegistryKey>
> </Component>
>
> <Component Id='RegKeySettingsDir' Guid='*' Permanent='yes'>
> <RegistryKey Root='HKLM' Key='SOFTWARE\CoolApp\8'>
> <RegistryValue Name="Settings_Directory" Type='string'
> Value='[PROJFOLDER]'/>
> </RegistryKey>
> </Component>
>
> Is this a better (cleaner? preferable?) way to structure the code?
>
> thanks for helping me sort this out!
>
> Todd Hoatson
> Mobile: 763-291-3312
> Email: todd.hoatson at gmail.com
> www.linkedin.com/in/toddhoatson
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
More information about the wix-users
mailing list