How to create Registry Entries in WiX 3.11 Installer for VSTO Add-ins deployment - wix

I'm trying to create a Windows Installer for deploying a MS Office VSTO Add-In. As we may know, one of the requirements for installing a VSTO AddIn is to create Registry Entries for VSTO. Question: How we can create such Registry Entries for VSTO in WiX 3.11?

You create registry values in WiX following the pattern:
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="PUT-GUID-HERE">
<RegistryKey Root="HKCU"
Key="Software\Microsoft\MyApplicationName"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer" Name="SomeIntegerValue" Value="1" KeyPath="yes"/>
<RegistryValue Type="string" Value="Default Value"/>
</RegistryKey>
</Component>
</DirectoryRef>
See WiX documentation

Related

Changing registry entry set by WiX

I'm new to WiX. I need to change the following registry-setting element:
<Component Id="BrowserEmulation" Directory="ApplicationProgramsFolder" Guid="*">
<RegistryValue Root="HKCU" Key="Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" Name="MY_REG_ENTRY" Value="11000" Type="integer" KeyPath="yes"/>
</Component>
So that the registry entry gets installed under HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER. I tried changing the Root value and the Key value:
<Component Id="BrowserEmulation" Directory="ApplicationProgramsFolder" Guid="*">
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" Name="MY_REG_ENTRY" Value="11000" Type="integer" KeyPath="yes"/>
</Component>
I also tried removing the KeyPath component. But when I try to build the .msi I get the following error:
error LGHT0204: ICE38: Component Browser Emulation installs to user
profile. It's KeyPath registry key must fall under HKCU
I looked at the WiX docs that describe Component KeyPaths but wasn't able to figure out how to get around this.
Directory: Looks like you need to take out the Directory attribute from your component. Maybe try something like this:
<Component Feature="MainApplication">
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" Name="MY_REG_ENTRY" Value="11000" Type="integer" KeyPath="yes"/>
</Component>
Bitness: Also be aware of the issue with 32-bit and 64-bit registry hives in HKLM: HKLM\SOFTWARE\WOW6432Node etc... Please see this answer for more details. I have inlined the most important part:
Registry:
64-Bit: HKEY_LOCAL_MACHINE\SOFTWARE
32-Bit: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
64-Bit: Maybe what you need is to mark your component as a 64-bit component? In order to write under HKEY_LOCAL_MACHINE\SOFTWARE?:
<Component Feature="MainApplication" Win64="yes">
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" Name="MY_REG_ENTRY" Value="11000" Type="integer" KeyPath="yes"/>
</Component>

WiX Installer removes shortcut on upgrade

I am using the WiX Toolkit v3.11 for creating setups of my software. During installation I create startmenu shortcuts with the following code:
<Shortcut Id='startmenuMyProgram'
Name='$(var.MyProgramName)'
Directory='ProgramMenuFolder'
WorkingDirectory='APPLICATIONFOLDER'
Advertise='yes'
Icon='icon.exe'>
<Icon Id='icon.exe' SourceFile='$(var.Setuppath)\MyProgram.exe'/>
</Shortcut>
In this way I also create two shortcuts for other executables. Now for the uninstall I want to remove the shortcuts.
<Component Id="removeStartmenuShortcuts" Guid="803ad14a-feab-4901-b9db-2c4a1298ae8b">
<Condition>(REMOVE=ALL) AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE)</Condition>
<RemoveFile Id="remove_startmenuProgram1" Name="startmenuMyProgram" On="uninstall" />
<RemoveFile Id="remove_startmenuProgram2" Name="startmenuMyProgram2" On="uninstall"/>
<RemoveFile Id="remove_startmenuProgram3" Name="startmenuMyProgram3" On="uninstall"/>
</Component>
This works without any problems when I uninstall the software. But the shortcuts are also removed when an update is performed. But I want to prevent this behavior, but the condition seems not to work. So all shortcuts like in the Windows task bar are removed when I do an update.
How can I make my update progress work correctly?
Here the behavior after update:
The group with all shortcuts in the right is missing!
You can combine the 2 component. By this you will not need to use condition statements.
The registry value is to set a keypath under component.
<Component Id="cmpstartmenuMyProgram" Guid="{67CB4F7A-5028-4697-A47F-DE99110B9645}">
<Shortcut Id="Shortcut.ApplicationName"
Name="ApplicationName"
Target="[INSTALLDIR]ApplicationName.exe"
WorkingDirectory="INSTALLDIR"
Directory="StartMenuFolder"
Icon="Icon.exe"/>
<RemoveFile Id="RemoveStartMenuShortcut.ApplicationName" Name="ApplicationName" Directory="StartMenuFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Compony\ComponyName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>

Wix shortcut desktop - is this code for current user or all users

I am trying to create a shortcut for all users using Wix 3.6. My InstallScope is perMachine and InstallPriviledges is elevated. I build this code ok. It runs ok. Does this produce a shortcut for all users or just the current user and what do I need to change to make a shortcut for all users?
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationDesktopShortcut" Guid="*">
<Shortcut Id="MyClient_DesktopShortcut" Name="My Client"
Description="My Client" Target="[INSTALLFOLDER]MyClient.exe"
WokingDirectory="INSTALLFOLDER" />
<RegistryValue Root="HKCU" Key="Software\MyServices\My Client\DesktopShortcut"
Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
Thanks
Jason

How can I record a 32-bit key in the registry on a 64-bit machine using WiX?

I have this key:
<Package
InstallerVersion="200"
Compressed="yes"
SummaryCodepage="1251"
Platform="x64"
InstallScope="perMachine"/>
<Component Id="RegistryEntries1" Guid="*">
<RegistryKey Root="HKLM"
Key="Software\SolidWorks\Addins\{GUID-PLACEHOLDER}"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer" Value="0"/>
<RegistryValue Name="Description" Value="SomeText" Type="string"/>
<RegistryValue Name="Title" Value="ProductName" Type="string"/>
</RegistryKey>
</Component>
This key needs to be written in the 32-bit registry section, even if the Windows edition is 64-bit. How can I do this?
As #PhilDW correctly pointed out, your installation package platform is targeting the x64 but your registry key is being created in the Wow6432Node. This node is a source of confusion for me, so here is its definition:
The Wow6432Node registry entry indicates that you are running a 64-bit Windows version. The operating system uses this key to display a separate view of HKEY_LOCAL_MACHINE\SOFTWARE for 32-bit applications that run on 64-bit Windows versions.
Since the registry key is being created in the HKLM\SOFTWARE\Wow6432Node\SolidWorks\Addins\, it means it's 32-bit. If you want to explicitly create it for 64-bit, add the Win64="yes" attribute to the Component.
<Component Id="RegistryEntries1" Guid="*" Win64="yes">
<RegistryKey Root="HKLM"
Key="Software\SolidWorks\Addins\{GUID-PLACEHOLDER}"
Action="createAndRemoveOnUninstall">
...
</RegistryKey>
</Component>

Generating an executable using wix

I am learning Wix and I want to generate a setup.exe file instead of a setup.msi.
Is that possible?
A setup EXE is usually referred to as a bootstrapper or chainer. WiX 3.5 will ship with an executable called burn.exe, unfortunately this is still under heavy development.
If you're just after a basic self-extracting EXE with no additional logic you can use the included setupbld.exe with WiX. However it's pretty limited and only includes the most basic functionality.
Alternatively, 7-zip includes basic functionality for creating a setup.exe from an existing MSI. You will need to install the SFXs for installers addon first.
If you're after additional logic, dependency checking, etc. there are loads of alternatives. Personally I use IRMakeBootstrap, but have heard very good things about dotNetInstaller on the wix-users mailing list.
dotNetInstaller
IRMakeBootstrap (Commercial product, licensed as part of MSI Factory)
Visual Studio Bootstrapper (Supports dependencies, not sure about self-extracting exe though)
step 1.Create window application
step 2. Add setp project
step 3. Add reference
1.WixNetFxExtension.dll
2.WixNetFxExtension.dll
3.WixNetFxExtension.dll
step 4. Add folowing code
<Component Id="ProductComponent">
<File Id="installation"
source="E:\MyWork\WindowsFormsApplication2\
WindowsFormsApplication2\bin\Debug/
WindowsFormsApplication2.exe"/>
<!-- TODO: Insert files, registry keys, and other
resources here. -->
</Component>
step 5. <Property Id="WIXUI_INSTALLDIR"
Value="INSTALLFOLDER" ></Property>
<UIRef Id="WixUI_InstallDir"/>
step 6.
<Directory Id="DesktopFolder" Name="Desktop"/>
<Directory Id="INSTALLFOLDER" Name="SetupProject1"
/>
step 7. <ComponentRef
Id="ApplicationShortcutDesktop"/>
step 8.<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop"
Guid="cde1e030-eb64-49a5-b7b8-400b379c2d1a">
<Shortcut Id="ApplicationDesktopShortcut"
Name="SetupProject1" Description="SetupProject1"
Target=".
[INSTALLFOLDER]WindowsFormsApplication2.exe"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="RemoveDesktopFolder"
Directory="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\SetupProject1" Name="installed"
Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
step 9.build and install setup