title: How to deploy a SharpShell-based shell extension via WiX?
body: <p>I have written this simplistic shell extension (explorer context menu) with SharpShell:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[ComVisible(true)]
  [COMServerAssociation(AssociationType.AllFiles)]
  public class SampleExtension : SharpContextMenu
  {
      protected override bool CanShowMenu()
      {
          return true;
      }
      protected override ContextMenuStrip CreateMenu()
      {
          var menu = new ContextMenuStrip();
          var item = new ToolStripMenuItem
          {
              Text = "Hello world!"
          };
          menu.Items.Add(item);
          return menu;
      }
  }
  </code></pre>
  
  <p>It works fine when I deploy it manually.  </p>
  
  <p>Based on <a href="http://www.epicgadgeteers.com/2014/02/sharpshell-part-2-deploying-your-windows-shell-extension-using-wix/" rel="nofollow noreferrer">William's instructions</a>, I wrote the WiX script below to install the shell extension on 32bit PCs:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='windows-1252'?&gt;
  &lt;Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'&gt;
  
    &lt;Product Name='Sample Extension' Id='PUT-GUID-HERE' 
              UpgradeCode='PUT-GUID-HERE' Language='1033' Codepage='1252'
              Version='0.1.23' Manufacturer='Me'&gt;
  
      &lt;Package Id='*' Keywords='Installer' Description="Sample Extension Setup"
               Manufacturer='Me' InstallerVersion='200' Languages='1033' 
               Compressed='yes' SummaryCodepage='1252' InstallScope='perMachine'
               Platform='x86'/&gt;
  
      &lt;Media Id='1' Cabinet='SampleExtension.cab' EmbedCab='yes' 
             DiskPrompt='Sample CAB' /&gt;
      &lt;Property Id='DiskPrompt' 
                Value="SampleExtension Bundle CAB Installation" /&gt;
  
      &lt;Directory Id='TARGETDIR' Name='SourceDir'&gt;
        &lt;Directory Id='ProgramFilesFolder' Name='PFiles'&gt;
          &lt;Directory Id='INSTALLDIR' Name='SampleExtension'&gt;
            &lt;Component Id='Libraries' Guid='*'&gt;
              &lt;File Id='SampleExtension.dll' Name='SampleExtension.dll'
                    Source='SampleExtension\bin\Debug\SampleExtension.dll' 
                    DiskId='1' /&gt;
              &lt;File Id='SharpShell.dll' Name='SharpShell.dll' 
                    Source='SampleExtension\bin\Debug\SharpShell.dll' 
                    DiskId='1' /&gt;
              &lt;File Id="SrmExe" Source="Extras\srm.exe"/&gt;
            &lt;/Component&gt;
          &lt;/Directory&gt;
        &lt;/Directory&gt;
      &lt;/Directory&gt;
  
      &lt;CustomAction Id="InstallShell" FileKey="SrmExe" 
            ExeCommand='install "[INSTALLFOLDER]\Application.dll" -codebase'
            Execute="deferred" Return="check" Impersonate="no" /&gt;
      &lt;CustomAction Id="UninstallShell" FileKey="SrmExe" 
            ExeCommand='uninstall "[INSTALLFOLDER]\Application.dll"'
            Execute="deferred" Return="check" Impersonate="no" /&gt;
      &lt;InstallExecuteSequence&gt;
        &lt;Custom Action="InstallShell" 
          After="InstallFiles"&gt;NOT Installed
        &lt;/Custom&gt;
        &lt;Custom Action="UninstallShell" 
          Before="RemoveFiles"&gt;(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
        &lt;/Custom&gt;
      &lt;/InstallExecuteSequence&gt;
  
  
      &lt;Feature Id='SampleExtensionFeature' Title='Sample' Description='Sample' 
               Level='1' AllowAdvertise='no'&gt;
        &lt;ComponentRef Id="Libraries" /&gt;
      &lt;/Feature&gt;
  
      &lt;Property Id="MSIUSEREALADMINDETECTION" Value="1" /&gt;
      &lt;Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /&gt;
      &lt;WixVariable Id="WixUILicenseRtf" Value="license.rtf" /&gt;
      &lt;UI&gt;&lt;UIRef Id="WixUI_InstallDir" /&gt;&lt;/UI&gt;
    &lt;/Product&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <p>But after installing the MSI, the shell context menu does not appear. <a href="http://www.nirsoft.net/utils/shexview.html" rel="nofollow noreferrer">ShellExView</a> does not even show it:</p>
  
  <p><img src="https://i.stack.imgur.com/IoWoU.png" alt="ShellExView SharpShell WiX"></p>
  
  <p>Here is the MSI log part that mentions <code>srm</code>, it is not really understandable for me:</p>
  
  <pre><code>Executing op: FileCopy(SourceName=srm.exe,SourceCabKey=SrmExe,DestName=srm.exe,Attributes=512,FileSize=151552,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,Version=2.1.0.0,Language=0,InstallMode=58982400,,,,,,,)
  File: C:\Program Files\CmisSyncShellExtension\srm.exe;  To be installed;    Won't patch;    No existing file
  Source for file 'SrmExe' is compressed
  InstallFiles: File: srm.exe,  Directory: C:\Program Files\CmisSyncShellExtension\,  Size: 151552
  Executing op: CacheSizeFlush(,)
  Executing op: ActionStart(Name=InstallShell,,)
  Action 18:30:13: InstallShell. 
  Executing op: CustomActionSchedule(Action=InstallShell,ActionType=3090,Source=C:\Program Files\CmisSyncShellExtension\srm.exe,Target=install "\Application.dll" -codebase,)
  Executing op: ActionStart(Name=RegisterProduct,Description=Registering product,Template=[1])
  Action 18:30:13: RegisterProduct. Registering product
  </code></pre>