[wix-users] Installing .NET .config files into the GAC

* * forforumhelp at hotmail.com
Fri May 13 05:11:08 PDT 2016




Hello
 
I'm facing the task of writing an installer with multiple features. The files installed by those features all rely on the same .NET assemblies which will also be installed by the installer package. All files of a feature will be installed into a dedicated subfolder. Now, because all features rely on the same bunch of assemblies I would like to install those shared assemblies into the Global Assembly Cache (GAC). That way all assemblies of all features will be able to utilize the shared assemblies installed in the GAC.
 
I'm well aware of the dangers of the GAC and all issues that go along with it. This is all fine, I want to use the GAC nonetheless :-)
 
The problem here is that some of the dlls that will be put into the GAC have associated .config files. In earlier times this would have been a problem because the GAC could not store such .config files. However, nowadays this does not seem to be an issue anymore because it is possible to store .config files in the GAC. First of all I searched the GAC and there are Microsoft assemblies that contain associated .config files in the same GAC folder as the associated assembly. Second, this issue was discussed in https://social.msdn.microsoft.com/Forums/vstudio/en-US/2710647c-6414-42c4-90b7-fd7603f55ae0/how-to-use-config-file-if-dll-is-in-gac?forum=netfxbcl which confirms my observation.
 
Now, the question really is how can I deploy my .config file at the same GAC location as my assembly?
 
I've tried it using a small demo project which deploys a strong named assembly to the GAC (Assembly=".net"). Since Assembly=".net" of course does not work for the associated .config file (which is not a strong named assembly and hence cannot be installed that way) I tried to instruct Windows Installer to deploy that file to the necessary location by just specifying the path to the GAC:
 
<?xml version="1.0" encoding="UTF-8"?> 

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 

  <Product Id="*"

           Name="GacInstaller"

           Language="1033"

           Version="1.0.0.0"

           Manufacturer="Microsoft"

           UpgradeCode="383DE40F-195F-4FD4-BEAD-234EDB2F63B5">

    <Package InstallerVersion="200"

             Compressed="yes"
             InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />


    <MediaTemplate EmbedCab="yes"
                   CompressionLevel="high"/>
    <Feature Id="ProductFeature"
             Title="GacInstaller"
             Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>

  </Product>


  <Fragment>

    <Directory Id="TARGETDIR" Name="SourceDir"/>

  </Fragment>


  <Fragment>


    <DirectoryRef Id="TARGETDIR">


      <Component Id="Component_GacInstallationTest.exe"
                 Guid="64C9A6BF-941D-461E-804F-6FFE3EA96A4E"
                 DiskId="1">
        <File Id="File_GacInstallationTest.exe"
              Source="$(var.BinDir)\GacInstallationTest.exe"
              KeyPath="yes"
              Vital="yes"
              Assembly=".net"/>
      </Component>
      <Directory           Id="WindowsFolder">
        <Directory         Id="DNetFolder"          Name="Microsoft.NET">
          <Directory       Id="GlobalAssemblyCache" Name="assembly">
            <Directory     Id="GAC_MSIL"            Name="GAC_MSIL">
              <Directory   Id="AssemblyNameFolder"  Name="!(bind.assemblyName.File_GacInstallationTest.exe)">
                <Directory Id="SignatureFolder"     Name="v4.0_!(bind.assemblyVersion.File_GacInstallationTest.exe)__!(bind.assemblyPublicKeyTokenPreservedCase.File_GacInstallationTest.exe)">
                  <Component Id="Component_GacInstallationTest.exe.config"
                             Guid="*"
                             DiskId="1">
                    <File Id="File_GacInstallationTest.exe.config"
                          Source="$(var.BinDir)\GacInstallationTest.exe.config"
                          KeyPath="yes"
                          Vital="yes"/>
                  </Component>
                </Directory>
              </Directory>
            </Directory>
          </Directory>
        </Directory>
      </Directory>
    </DirectoryRef> 
    <ComponentGroup Id="ProductComponents"
                    Directory="TARGETDIR">
      <ComponentRef Id="Component_GacInstallationTest.exe"/>
      <ComponentRef Id="Component_GacInstallationTest.exe.config"/>
    </ComponentGroup>
  </Fragment>
</Wix> 
The problem is that GacInstallationTest.exe.config is never installed into the proper location. It's just not appearing there and the installation log file gives me no hint at all why not. If I append a "_" at the SignatureFolder I can clearly see that the file gets installed inside the specified folder. So the behaviour is that my config file is not installed if the target directory is the same as for the exe. Any other directory inside the GAC can be targeted and the config file appears there correctly. It's just that if I point to the exact same folder as the exe file the config file does not appear. I can only speculate at this point but I can well imagine that the installation of the .exe file somehow could remove the .config which might already be there. However, this is pure speculation. There are of course simple ways to fix this. I could install the files somewhere else than the GAC, forget about it and finish my installer project. However, this issue makes me curious and I would like to know if it is somehow possible to deploy .config files to the GAC using Windows Installer. Help to achieve this is appreciated. RegardsACKH
 
 		 	   		  


More information about the wix-users mailing list