Search code examples
wixgac

Install to GAC and register in registry


Okay, I'm obviously missing something. I'm trying to follow this in order to install to GAC and also make available for development. However, the only thing that's happening is that the DLL is being dropped into the ProductDirectory. It's not appearing in the GAC, nor is the registry key being added. How can I get this to work?

Relevant parts of Product.wxs below.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="Me.Common" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="ea52947a-0980-435d-a8f5-280d3526cb90">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <!-- The feature to install. -->
        <Feature Id="ProductFeature" Title="Me.Common" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="ProductDirectory" Name="Me.Common">
          <Directory Id="GAC" Name="GAC" />
        </Directory>
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents">
      <Component Id="RunTime_Me.Common" Directory="GAC" Guid="E2B19C22-DC01-432D-85B0-0E4948F95A43">
        <!-- Add to GAC. -->
        <File Id="RunTime_Me.Common"
              Source="$(var.Me.Common.TargetDir)$(var.Me.Common.TargetFileName)"
              Assembly=".net"
              KeyPath="yes" />
      </Component>
      <Component Id="DesignTime_Me.Common" Directory="ProductDirectory" Guid="C1BD8CD1-E834-49D5-B499-D9E313E70669">
        <!-- Add locally. -->
        <File Id="DesignTime_Me.Common"
              Source="$(var.Me.Common.TargetDir)$(var.Me.Common.TargetFileName)"
              KeyPath="yes" />
        <!-- Add to registry so that Visual Studio can find it via Add Reference. -->
        <Registry Id="Registry_DesignTime_Me.Common_AssemblyFolders"
                  Root="HKLM"
                  Key="SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\[ProductName]"
                  Value="[$DesignTime_Me.Common]"
                  Type="string" />
      </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

Turns out it was already installing in the GAC. I was looking in the wrong place; .NET now has a second GAC for 4.0 items (C:\Windows\Microsoft.NET\assembly). That leaves the registry key. I was getting a warning that Registry is deprecated, so I replaced that component with the below, but still not working:

  <Component Id="DesignTime_Me.Common" Directory="ProductDirectory" Guid="C1BD8CD1-E834-49D5-B499-D9E313E70669">
    <!-- Add locally. -->
    <File Id="DesignTime_Me.Common"
          Source="$(var.Me.Common.TargetDir)$(var.Me.Common.TargetFileName)"
          KeyPath="yes" />
    <!-- Add to registry so that Visual Studio can find it via Add Reference.
         These require .NET v4.0 minimum. -->
    <RegistryKey Root="HKLM"
                 Key="SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\[ProductName]">
      <RegistryValue Type="string" Value="[$DesignTime_Me.Common]" />
    </RegistryKey>
  </Component>
</ComponentGroup>

Solution

  • It's all working; I was just looking in the wrong places.

    The 4.0 GAC is at C:\Windows\Microsoft.NET\assembly. The registry key is being placed in SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\[ProductName] because the installer is 32-bit.