Wixsharp: Why are not registry keys created?

Created on 27 Apr 2019  路  5Comments  路  Source: oleg-shilo/wixsharp

Using WiX Sharp I'm generating the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
   <Product Id="41c39b6f-a22c-4502-92d2-32c057e6e6d5" Name="Zech Office Word Automation Add-in 1" Language="1033" Codepage="Windows-1252" Version="1.0.0.0" UpgradeCode="c4d368a8-a929-41fa-94d5-a66f5a058bc6" Manufacturer="Zeta Software GmbH">
      <Package InstallerVersion="200" Compressed="yes" SummaryCodepage="Windows-1252" Languages="1033" />
      <Media Id="1" Cabinet="_21a70e2c5d3641b3a2d6cdbf396d8259.cab" EmbedCab="yes" />
      <Directory Id="TARGETDIR" Name="SourceDir">
         <Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
            <Directory Id="INSTALLLDIR" Name="Zech Office Word Automation Add-in 1">
               <Component Id="Component.settings.json_1764837082" Guid="41c39b6f-a22c-4502-92d2-32c0f350c572">
                  <File Id="settings.json_1764837082" Source="..\Temp-MSI-Sources\636919708562543530\settings.json" />
               </Component>
               <Component Id="Component.setup.exe_1007431216" Guid="41c39b6f-a22c-4502-92d2-32c090433ffa">
                  <File Id="setup.exe_1007431216" Source="..\Temp-MSI-Sources\636919708562543530\setup.exe" />
               </Component>
               <Component Id="Component.Zech.OfficeDocAuto.Word2016AddIn.vsto_1379265732" Guid="41c39b6f-a22c-4502-92d2-32c0f6d493bf">
                  <File Id="Zech.OfficeDocAuto.Word2016AddIn.vsto_1379265732" Source="..\Temp-MSI-Sources\636919708562543530\Zech.OfficeDocAuto.Word2016AddIn.vsto" />
               </Component>
               <Directory Id="INSTALLLDIR.Application_Files" Name="Application Files">
                  <Directory Id="INSTALLLDIR.Application_Files.Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3" Name="Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3">
                     <Component Id="Component.AsyncBridge.dll.deploy_611603868" Guid="41c39b6f-a22c-4502-92d2-32c0f9219266">
                        <File Id="AsyncBridge.dll.deploy_611603868" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\AsyncBridge.dll.deploy" />
                     </Component>
                     <Component Id="Component.JetBrains.Annotations.dll.deploy_1156774332" Guid="41c39b6f-a22c-4502-92d2-32c074acaea9">
                        <File Id="JetBrains.Annotations.dll.deploy_1156774332" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\JetBrains.Annotations.dll.deploy" />
                     </Component>
                     <Component Id="Component.LiteDB.dll.deploy_450708562" Guid="41c39b6f-a22c-4502-92d2-32c00dee8cbe">
                        <File Id="LiteDB.dll.deploy_450708562" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\LiteDB.dll.deploy" />
                     </Component>
                     <Component Id="Component.Microsoft.Office.Tools.Common.v4.0.Utilities.dll.deploy_1167386081" Guid="41c39b6f-a22c-4502-92d2-32c0eee81c2c">
                        <File Id="Microsoft.Office.Tools.Common.v4.0.Utilities.dll.deploy_1167386081" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Microsoft.Office.Tools.Common.v4.0.Utilities.dll.deploy" />
                     </Component>
                     <Component Id="Component.MoreLinq.dll.deploy_1387397510" Guid="41c39b6f-a22c-4502-92d2-32c0ec396e2f">
                        <File Id="MoreLinq.dll.deploy_1387397510" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\MoreLinq.dll.deploy" />
                     </Component>
                     <Component Id="Component.Newtonsoft.Json.dll.deploy_1389234194" Guid="41c39b6f-a22c-4502-92d2-32c04716b757">
                        <File Id="Newtonsoft.Json.dll.deploy_1389234194" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Newtonsoft.Json.dll.deploy" />
                     </Component>
                     <Component Id="Component.NLog.dll.deploy_1363552021" Guid="41c39b6f-a22c-4502-92d2-32c01e1323b3">
                        <File Id="NLog.dll.deploy_1363552021" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\NLog.dll.deploy" />
                     </Component>
                     <Component Id="Component.System.Configuration.ConfigurationManager.dll.deploy_31595820" Guid="41c39b6f-a22c-4502-92d2-32c031c04c6f">
                        <File Id="System.Configuration.ConfigurationManager.dll.deploy_31595820" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\System.Configuration.ConfigurationManager.dll.deploy" />
                     </Component>
                     <Component Id="Component.System.Security.AccessControl.dll.deploy_503483800" Guid="41c39b6f-a22c-4502-92d2-32c084cf0d7e">
                        <File Id="System.Security.AccessControl.dll.deploy_503483800" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\System.Security.AccessControl.dll.deploy" />
                     </Component>
                     <Component Id="Component.System.Security.Permissions.dll.deploy_1422876833" Guid="41c39b6f-a22c-4502-92d2-32c0dcad6f21">
                        <File Id="System.Security.Permissions.dll.deploy_1422876833" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\System.Security.Permissions.dll.deploy" />
                     </Component>
                     <Component Id="Component.System.Security.Principal.Windows.dll.deploy_494552073" Guid="41c39b6f-a22c-4502-92d2-32c039b2a51f">
                        <File Id="System.Security.Principal.Windows.dll.deploy_494552073" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\System.Security.Principal.Windows.dll.deploy" />
                     </Component>
                     <Component Id="Component.System.ValueTuple.dll.deploy_821523869" Guid="41c39b6f-a22c-4502-92d2-32c06ac3b254">
                        <File Id="System.ValueTuple.dll.deploy_821523869" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\System.ValueTuple.dll.deploy" />
                     </Component>
                     <Component Id="Component.Zech.OfficeDocAuto.Runtime.dll.deploy_74928943" Guid="41c39b6f-a22c-4502-92d2-32c0965ccb1c">
                        <File Id="Zech.OfficeDocAuto.Runtime.dll.deploy_74928943" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Zech.OfficeDocAuto.Runtime.dll.deploy" />
                     </Component>
                     <Component Id="Component.Zech.OfficeDocAuto.Word2016AddIn.dll.config.deploy_1275612656" Guid="41c39b6f-a22c-4502-92d2-32c06f265f99">
                        <File Id="Zech.OfficeDocAuto.Word2016AddIn.dll.config.deploy_1275612656" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Zech.OfficeDocAuto.Word2016AddIn.dll.config.deploy" />
                     </Component>
                     <Component Id="Component.Zech.OfficeDocAuto.Word2016AddIn.dll.deploy_422849095" Guid="41c39b6f-a22c-4502-92d2-32c017db09fa">
                        <File Id="Zech.OfficeDocAuto.Word2016AddIn.dll.deploy_422849095" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Zech.OfficeDocAuto.Word2016AddIn.dll.deploy" />
                     </Component>
                     <Component Id="Component.Zech.OfficeDocAuto.Word2016AddIn.dll.manifest_322905321" Guid="41c39b6f-a22c-4502-92d2-32c0afae3cac">
                        <File Id="Zech.OfficeDocAuto.Word2016AddIn.dll.manifest_322905321" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Zech.OfficeDocAuto.Word2016AddIn.dll.manifest" />
                     </Component>
                     <Component Id="Component.Zech.OfficeDocAuto.Word2016AddIn.vsto_271636196" Guid="41c39b6f-a22c-4502-92d2-32c03da3295a">
                        <File Id="Zech.OfficeDocAuto.Word2016AddIn.vsto_271636196" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\Zech.OfficeDocAuto.Word2016AddIn.vsto" />
                     </Component>
                     <Component Id="Component.ZetaShortPaths.dll.deploy_452371855" Guid="41c39b6f-a22c-4502-92d2-32c02755a1f4">
                        <File Id="ZetaShortPaths.dll.deploy_452371855" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\ZetaShortPaths.dll.deploy" />
                     </Component>
                     <Directory Id="INSTALLLDIR.Application_Files.Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3.de" Name="de">
                        <Component Id="Component.ZetaShortPaths.resources.dll.deploy_1449466157" Guid="41c39b6f-a22c-4502-92d2-32c00211e4f1">
                           <File Id="ZetaShortPaths.resources.dll.deploy_1449466157" Source="..\Temp-MSI-Sources\636919708562543530\Application Files\Zech.OfficeDocAuto.Word2016AddIn_1_0_0_3\de\ZetaShortPaths.resources.dll.deploy" />
                        </Component>
                     </Directory>
                  </Directory>
               </Directory>
            </Directory>
            <Component Id="Registry.1" Guid="41c39b6f-a22c-4502-92d2-32c04403b453" KeyPath="yes">
               <RegistryKey Root="HKLM" Key="Software\Microsoft\Office\Word\Addins\Zech.OfficeDocAuto.Word2016AddIn" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
                  <RegistryValue Id="Description" Type="string" KeyPath="no" Value="Zech-Add-in f眉r automatisierte Office-Dokumente" Name="Description" />
               </RegistryKey>
               <CreateFolder />
               <RemoveFolder Id="ProgramFilesFolder" On="uninstall" />
            </Component>
            <Component Id="Registry.2" Guid="41c39b6f-a22c-4502-92d2-32c04404b453">
               <RegistryKey Root="HKLM" Key="Software\Microsoft\Office\Word\Addins\Zech.OfficeDocAuto.Word2016AddIn" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
                  <RegistryValue Id="FriendlyName" Type="string" KeyPath="yes" Value="Zech-Office-Automation-Word-Add-in" Name="FriendlyName" />
               </RegistryKey>
               <CreateFolder />
            </Component>
            <Component Id="Registry.3" Guid="41c39b6f-a22c-4502-92d2-32c04405b453">
               <RegistryKey Root="HKLM" Key="Software\Microsoft\Office\Word\Addins\Zech.OfficeDocAuto.Word2016AddIn" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
                  <RegistryValue Id="LoadBehavior" Type="integer" KeyPath="yes" Value="3" Name="LoadBehavior" />
               </RegistryKey>
               <CreateFolder />
            </Component>
            <Component Id="Registry.4" Guid="41c39b6f-a22c-4502-92d2-32c044feb453">
               <RegistryKey Root="HKLM" Key="Software\Microsoft\Office\Word\Addins\Zech.OfficeDocAuto.Word2016AddIn" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
                  <RegistryValue Id="Manifest" Type="string" KeyPath="yes" Value="[INSTALLFOLDER]Zech.OfficeDocAuto.Word2016AddIn.vsto|vstolocal" Name="Manifest" />
               </RegistryKey>
               <CreateFolder />
            </Component>
         </Directory>
      </Directory>
      <UIRef Id="WixUI_InstallDir" />
      <UIRef Id="WixUI_ErrorProgressText" />
      <Property Id="ALLUSERS" Value="1" />
      <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLDIR" />
      <Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
         <ComponentRef Id="Component.settings.json_1764837082" />
         <ComponentRef Id="Component.setup.exe_1007431216" />
         <ComponentRef Id="Component.Zech.OfficeDocAuto.Word2016AddIn.vsto_1379265732" />
         <ComponentRef Id="Component.AsyncBridge.dll.deploy_611603868" />
         <ComponentRef Id="Component.JetBrains.Annotations.dll.deploy_1156774332" />
         <ComponentRef Id="Component.LiteDB.dll.deploy_450708562" />
         <ComponentRef Id="Component.Microsoft.Office.Tools.Common.v4.0.Utilities.dll.deploy_1167386081" />
         <ComponentRef Id="Component.MoreLinq.dll.deploy_1387397510" />
         <ComponentRef Id="Component.Newtonsoft.Json.dll.deploy_1389234194" />
         <ComponentRef Id="Component.NLog.dll.deploy_1363552021" />
         <ComponentRef Id="Component.System.Configuration.ConfigurationManager.dll.deploy_31595820" />
         <ComponentRef Id="Component.System.Security.AccessControl.dll.deploy_503483800" />
         <ComponentRef Id="Component.System.Security.Permissions.dll.deploy_1422876833" />
         <ComponentRef Id="Component.System.Security.Principal.Windows.dll.deploy_494552073" />
         <ComponentRef Id="Component.System.ValueTuple.dll.deploy_821523869" />
         <ComponentRef Id="Component.Zech.OfficeDocAuto.Runtime.dll.deploy_74928943" />
         <ComponentRef Id="Component.Zech.OfficeDocAuto.Word2016AddIn.dll.config.deploy_1275612656" />
         <ComponentRef Id="Component.Zech.OfficeDocAuto.Word2016AddIn.dll.deploy_422849095" />
         <ComponentRef Id="Component.Zech.OfficeDocAuto.Word2016AddIn.dll.manifest_322905321" />
         <ComponentRef Id="Component.Zech.OfficeDocAuto.Word2016AddIn.vsto_271636196" />
         <ComponentRef Id="Component.ZetaShortPaths.dll.deploy_452371855" />
         <ComponentRef Id="Component.ZetaShortPaths.resources.dll.deploy_1449466157" />
         <ComponentRef Id="Registry.1" />
         <ComponentRef Id="Registry.2" />
         <ComponentRef Id="Registry.3" />
         <ComponentRef Id="Registry.4" />
      </Feature>
   </Product>
</Wix>

On my target machine, I see that _no_ registry keys are bying created.

I've even fired up RegEdit and watched any registry operations; no operations are being performed.

My question:

Is there any reason why no registry keys and values are being created? Any fix for it?

All 5 comments

Is there a chance that you are installing on x64 machine? If so the registry will be created in the WOW registry hive and it may not be easy to find. This is because MSI is not transparent to CPU type and one has to create a dedicated MSI entry targeting x86 or x64 platforms.

Thus for x64 you should set Win64 property:
C# var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File(fullSetup, @"readme.txt")), new RegValue(fullSetup, RegistryHive.LocalMachine, @"Software\My Company\My Product", "Message", "Hello") { Win64 = true } , new RemoveRegistryKey(fullSetup, @"Software\My Company\My Product"))
The code above will create HKEY_LOCAL_MACHINE\SOFTWARE\My Company\My Product registry key.

And if you forget to set Win64 then the key will go to: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\My Company\My Product.

Another MSI quirk is that registry key are not deleted on uninstall!!! WiX team had to create the RemoveRegistryValue Element extension for that.

And this fact is reflected in the WiX documentation. But... in the section of a different _element_:

_RemoveRegistryValue Element_
Description
... There is no standard way to remove a single registry value during uninstall (but you can remove an entire key with RemoveRegistryKey).

Yep this the MSI beauty for you :(

Thanks a million times, Oleg, that helped my understanding what's going on and to (nearly) resolve everything.

As a follow-up to this, I currently have the "[INSTALLFOLDER]" placeholder inside a registry value:

<RegistryValue 
    Id="Manifest" 
    Type="string" 
    KeyPath="yes" 
    Value="[INSTALLFOLDER]Zech.OfficeDocAuto.Word2016AddIn.vsto|vstolocal" 
    Name="Manifest" />

When the MSI gets installed on the target machine, I see that it actually is replaced with an empty string.

I.e. the registry key reads

Zech.OfficeDocAuto.Word2016AddIn.vsto|vstolocal

Whereas it _should_ read:

C:\Program Files (x86)\Zech Office Word Automation Add-in 1\Zech.OfficeDocAuto.Word2016AddIn.vsto|vstolocal

Maybe you can give me a hint on how I can force WiX to actually replace the placeholder with the installation folder?

(I'm following this tutorial for the registry keys).

After looking at this, it seems I needed to use "[INSTALLDIR]" instead.

After changing, it still didn't work.

Taking a closer look at my generated XML and my source code, I found this:

var myRootDir = new Dir(
    new Id(@"INSTALLLDIR"),
    $"Zech Office Word Automation Add-in {trimVersion(passedVersionNumberVersion.ToString(1))}");

I had written "INSTALLLDIR" (three "L"s), instead of "INSTALLDIR"!

After changing it to "INSTALLDIR" (two "L"s), and using it in the registry key like this, everything works as expected:

wixObjects.Add(new RegValue(hive, regPath,
    @"Manifest",
    @"[INSTALLDIR]Zech.OfficeDocAuto.Word2016AddIn.vsto|vstolocal")
    { ForceCreateOnInstall = true, ForceDeleteOnUninstall = true });

Yep, you need to use INSTALLDIR. It is the id of the install directory. WixSharp assingns this ID to the install directory automatically but of course you can use your own ID. Even INSTALLFOLDER:
C# var project = new ManagedProject("My Product", new Dir(new Id("INSTALLFOLDER"), @"%ProgramFiles%\My Product", new File(...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CADbloke picture CADbloke  路  4Comments

Chrissyoung1223 picture Chrissyoung1223  路  5Comments

Eagle3386 picture Eagle3386  路  4Comments

ju2pom picture ju2pom  路  5Comments

Eagle3386 picture Eagle3386  路  6Comments